Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class PlayerMovement : MonoBehaviour {
- public Rigidbody rb;
- public float pushSpeed = 2000f;
- public float moveSpeed = 100f;
- // Runs once when starting game
- void Start () {
- }
- // Update is called once per frame
- void FixedUpdate () {
- if (Input.GetKey("d"))
- {
- rb.AddForce(moveSpeed * Time.fixedDeltaTime, 0, 0);
- }
- if (Input.GetKey("s"))
- {
- rb.AddForce(0, 0, -moveSpeed * Time.fixedDeltaTime);
- }
- if (Input.GetKey("a"))
- {
- rb.AddForce(-moveSpeed * Time.fixedDeltaTime, 0, 0);
- }
- if (Input.GetKey("w"))
- {
- rb.AddForce(0, 0, moveSpeed * Time.fixedDeltaTime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement