Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.ComponentModel.DataAnnotations.Schema;
- using UnityEngine;
- public class bewegung : MonoBehaviour
- {
- public Rigidbody rb;
- public float Forward = 200f;
- public float Left = 200f;
- public float Right = 200f;
- public float Backward = 200f;
- public float Up = 10f;
- void FixedUpdate()
- {
- switch (Mathf.RountToInt(Input.GetAxisRaw("Vertical")))
- {
- case -1:
- rb.AddForce(0, 0, Forward * Time.deltaTime, ForceMode.VelocityChange);
- break;
- case 1:
- rb.AddForce(0, 0, -Backward * Time.deltaTime, ForceMode.VelocityChange);
- break;
- }
- switch (Mathf.RountToInt(Input.GetAxisRaw("Horizontal")))
- {
- case -1:
- rb.AddForce(-Left * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
- break;
- case 1:
- rb.AddForce(Right * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
- break;
- }
- if (Input.GetKey("space"))
- if (transform.position.y <=1.05)
- {
- rb.AddForce(0, Up , 0, ForceMode.VelocityChange);
- }
- if (rb.position.y < -5f)
- {
- FindObjectOfType<Gamemanager>().EndGame();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement