Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class skiSimple1 : MonoBehaviour {
- public GameObject Body;
- Rigidbody BodyRb;
- public bool IsGrounded;
- private Rigidbody rb;
- public float Speed = 100.0f;
- public float RotateSpeed = 100.0f;
- public float FlipSpeed = 100.0f;
- public float BoostSpeed = 200.0f;
- public float JumpPower = 100.0f;
- void Start () {
- rb = GetComponent<Rigidbody>();
- BodyRb = Body.GetComponent<Rigidbody>();
- }
- void OnCollisionStay (Collision collisionInfo)
- {
- IsGrounded = true;
- }
- void OnCollisionExit (Collision collisionInfo)
- {
- IsGrounded = false;
- }
- void FixedUpdate() {
- float moveHorizontal = Input.GetAxis ("Horizontal");
- float moveVertical = Input.GetAxis ("Vertical");
- if (IsGrounded){
- if (Input.GetKey (KeyCode.Space)) {
- rb.AddRelativeForce (transform.up * JumpPower);
- }
- rb.AddForce (transform.forward * moveVertical * Speed);
- rb.AddTorque (transform.up * moveHorizontal * RotateSpeed);
- rb.AddTorque (transform.right * moveVertical * FlipSpeed*0.1f);
- rb.angularDrag= 2.0f;
- BodyRb.AddForce(transform.forward * moveVertical * Speed);
- }
- else {
- rb.angularDrag = 0.0f;
- //rb.AddTorque (transform.right * moveVertical * FlipSpeed);
- rb.AddTorque (transform.up * moveHorizontal * RotateSpeed*0.1F);
- BodyRb.AddTorque(transform.right * moveVertical * Speed);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment