Advertisement
Guest User

My Code

a guest
Nov 3rd, 2020
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using UnityEngine;
  5.  
  6. public class playermove : MonoBehaviour
  7. {
  8.     // Start is called before the first frame update
  9.     public float thrust = 9.0f;
  10.     public Rigidbody rb;
  11.     public float jumppower = 10.0f;
  12.     public float speed = 10.0f;
  13.     public GameObject ob;
  14.  
  15.  
  16.     void Start()
  17.     {
  18.         rb = GetComponent<Rigidbody>();
  19.     }
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.     // Update is called once per frame
  28.     void FixedUpdate()
  29.     {
  30.         if (ob.tag == "Player")
  31.         {
  32.         if (Input.GetKey(KeyCode.W))
  33.         {
  34.                 transform.Rotate(Vector3.forward);
  35.                 transform.position += Vector3.forward * Time.deltaTime * speed;
  36.         }
  37.  
  38.         if (Input.GetKey(KeyCode.S))
  39.         {
  40.                 transform.Rotate(Vector3.back);
  41.                 transform.position += Vector3.back * Time.deltaTime * speed;
  42.         }
  43.  
  44.         if (Input.GetKey(KeyCode.A))
  45.         {
  46.             transform.Rotate(Vector3.left);
  47.             transform.position += Vector3.left * Time.deltaTime * speed;
  48.            
  49.             }
  50.  
  51.         if (Input.GetKey(KeyCode.D))
  52.         {
  53.                 transform.Rotate(Vector3.right);
  54.                 transform.position += Vector3.right * Time.deltaTime * speed;
  55.         }
  56.  
  57.         if (Input.GetKey(KeyCode.Space))
  58.         {
  59.             transform.position += Vector3.up * Time.deltaTime * jumppower;
  60.         }
  61.         }
  62.        
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement