Advertisement
sphinx2001

ShipController

Feb 12th, 2020
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class NewController : MonoBehaviour
  6. {
  7.     public ConstantForce frc;
  8.     [Range(0.1f, 5f)]
  9.     public float verticalSensitivity = 1;
  10.     [Range(0.1f, 5f)]
  11.     public float horizontalSensitivity = 1;
  12.  
  13.     Rigidbody rig;
  14.  
  15.     // Use this for initialization
  16.     void Start()
  17.     {
  18.         rig = GetComponent<Rigidbody>();
  19.     }
  20.  
  21. void Update()
  22.     {
  23.         frc.relativeTorque = new Vector3(Input.GetAxis("Mouse Y") * 100f * verticalSensitivity,
  24.             Input.GetAxis("Horizontal") * 100f,
  25.             -Input.GetAxis("Mouse X") * 100f * horizontalSensitivity)
  26.             * Mathf.Clamp01(rig.velocity.magnitude / 100f);
  27.         frc.relativeForce = new Vector3(0, 0, Mathf.Clamp(Input.GetAxis("Vertical"), -0.1f, 1f) * 1000f);
  28.    
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement