Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class NewBehaviourScript : MonoBehaviour
- {
- public float moveSpeed;
- public float jumpHeight;
- Rigidbody2D rb;
- void Start()
- {
- rb = GetComponent<Rigidbody2D>();
- }
- void Update()
- {
- if (Input.GetKeyDown(KeyCode.Space))
- {
- rb.velocity = new Vector2(rb.velocity.x, jumpHeight);
- }
- if (Input.GetKey(KeyCode.D))
- {
- rb.velocity = new Vector2(moveSpeed, rb.velocity.y);
- }
- if (Input.GetKey(KeyCode.A))
- {
- rb.velocity = new Vector2(-moveSpeed, rb.velocity.y);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement