Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using System.Threading;
- using UnityEngine;
- public class playermove : MonoBehaviour
- {
- // Start is called before the first frame update
- public float thrust = 9.0f;
- public Rigidbody rb;
- public float jumppower = 10.0f;
- public float speed = 10.0f;
- public GameObject ob;
- void Start()
- {
- rb = GetComponent<Rigidbody>();
- }
- // Update is called once per frame
- void FixedUpdate()
- {
- if (ob.tag == "Player")
- {
- if (Input.GetKey(KeyCode.W))
- {
- transform.Rotate(Vector3.forward);
- transform.position += Vector3.forward * Time.deltaTime * speed;
- }
- if (Input.GetKey(KeyCode.S))
- {
- transform.Rotate(Vector3.back);
- transform.position += Vector3.back * Time.deltaTime * speed;
- }
- if (Input.GetKey(KeyCode.A))
- {
- transform.Rotate(Vector3.left);
- transform.position += Vector3.left * Time.deltaTime * speed;
- }
- if (Input.GetKey(KeyCode.D))
- {
- transform.Rotate(Vector3.right);
- transform.position += Vector3.right * Time.deltaTime * speed;
- }
- if (Input.GetKey(KeyCode.Space))
- {
- transform.position += Vector3.up * Time.deltaTime * jumppower;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement