Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 KB | None | 0 0
  1. public class Player : MonoBehaviour { public Rigidbody rigidBody; public AudioSource audioSource; public ParticleSystem flyPartical; public float rotSpeed; public float flySpeed; // Start is called before the first frame update void Start() { rigidBody = GetComponent<Rigidbody>(); audioSource = GetComponent<AudioSource>(); } // Update is called once per frame void Update() { Lounch(); Rotation(); } void Lounch() { if (Input.GetKey(KeyCode.Space) || Input.GetKey(KeyCode.W)) { rigidBody.AddRelativeForce(Vector3.up * flySpeed); if(audioSource.isPlaying == false) { audioSource.Play(); flyPartical.Play(); } } else { audioSource.Stop(); flyPartical.Stop(); } } void Rotation() { float rotationSpeed = rotSpeed * Time.deltaTime; rigidBody.freezeRotation = true; if(Input.GetKey(KeyCode.D)) { transform.Rotate(Vector3.forward * rotationSpeed); } else if(Input.GetKey(KeyCode.A)) { transform.Rotate(-Vector3.forward * rotationSpeed); } } public void ButtonUp() { print("вверх"); transform.Translate(Vector3.up); } public void ButtonLeft() { print("влево"); } public void ButtonRight() { print("вправо"); } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement