Advertisement
gfdhfgh

Untitled

Feb 22nd, 2022
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class movw : MonoBehaviour
  6. {
  7. Rigidbody2D rb;
  8. private float verticalMove;
  9.  
  10. [SerializeField] private float speed;
  11.  
  12. void Start()
  13. {
  14. rb = GetComponent<Rigidbody2D>();
  15.  
  16. }
  17.  
  18. private void Update()
  19. {
  20.  
  21. }
  22.  
  23. private void FixedUpdate()
  24. {
  25. transform.Translate(0, verticalMove, 0);
  26.  
  27. }
  28.  
  29. public void upButton()
  30. {
  31. verticalMove = speed;
  32. }
  33.  
  34. public void downButton()
  35. {
  36. verticalMove = -speed;
  37. }
  38.  
  39. public void Stop()
  40. {
  41. verticalMove = 0;
  42. }
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement