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 Player : MonoBehaviour
- {
- Rigidbody rb;
- public float s = 10f;
- public float score;
- public float rs = 10f;
- Vector3 v, r;
- public float j = 0f;
- // Start is called before the first frame update
- void Start()
- {
- rb = GetComponent<Rigidbody>();
- }
- // Update is called once per frame
- void Update()
- {
- float x = 0, y = 0, z = 0;
- float j = 0;
- if (Input.GetKey(KeyCode.W))
- {
- z = 1;
- }
- if (Input.GetKey(KeyCode.S))
- {
- z = -1;
- }
- if (Input.GetKey(KeyCode.D))
- {
- y = 1;
- }
- if (Input.GetKey(KeyCode.A))
- {
- y = -1;
- }
- if (Input.GetKey(KeyCode.Space))
- {
- if (transform.position.y <= 0.55)
- {
- j = 20;
- z += 1;
- }
- }
- v = new Vector3(x, j, z) * Time.deltaTime * s;
- r = new Vector3(0, y, 0) * rs;
- }
- private void FixedUpdate()
- {
- rb.AddTorque(r);
- rb.AddRelativeForce(v);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement