Advertisement
sphinx2001

Player_startship_controller

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