Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Movement : MonoBehaviour {
  6.  
  7. public float moveSpeed = 5f;
  8. // Start is called before the first frame update
  9. void Start() {
  10.  
  11.  
  12. }
  13.  
  14. // Update is called once per frame
  15. void Update() {
  16.  
  17. Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), 0f, 0f);
  18. transform.position += movement * Time.deltaTime * moveSpeed;
  19. }
  20.  
  21. void Jump() {
  22. if (Input.GetButtonDown("Jump"))
  23. {
  24.  
  25. }
  26.  
  27. {
  28. gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(0f, 5f), ForceMode2D.Impulse);
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement