Hi guys, i am trying to make a game where i can enter a boat and exit, how would i go about doing that thanks!!
(P.S if you do have a script i could use it would be much appreciated!)
Hi guys, i am trying to make a game where i can enter a boat and exit, how would i go about doing that thanks!!
(P.S if you do have a script i could use it would be much appreciated!)
// js adaptation by WarpZone
// Put this on a rigidbody object and instantly
// have 2D spaceship controls like OverWhelmed Arena
// that you can tweak to your heart's content.
@script RequireComponent (Rigidbody)
var hoverHeight : float = 120;
var hoverHeightStrictness : float = 1.0;
var forwardThrust : float = 5000.0;
var backwardThrust : float = 2500.0;
var bankAmount : float = 0.1;
var bankSpeed : float = 0.2;
var bankAxis : Vector3 = new Vector3(-1.0, 0.0, 0.0);
var turnSpeed : float = 8000.0;
var forwardDirection : Vector3 = new Vector3(0.0, 0.0, 1.0);
var mass : float = 5.0;
// positional drag
var sqrdSpeedThresholdForDrag : float = 25.0;
var superDrag : float = 2.0;
var fastDrag : float = 0.5;
var slowDrag : float = 0.01;
// angular drag
var sqrdAngularSpeedThresholdForDrag : float = 5.0;
var superADrag : float = 32.0;
var fastADrag : float = 16.0;
var slowADrag : float = 0.1;
var playerControl : boolean = true;
private var bank : float = 0.0;
function SetPlayerControl(control : boolean)
{
playerControl = control;
}
function Start()
{
gameObject.GetComponent.<Rigidbody>().mass = mass;
}
function FixedUpdate()
{
if (Mathf.Abs(thrust) > 0.01)
{
if (GetComponent.<Rigidbody>().velocity.sqrMagnitude > sqrdSpeedThresholdForDrag)
GetComponent.<Rigidbody>().drag = fastDrag;
else
GetComponent.<Rigidbody>().drag = slowDrag;
}
else
GetComponent.<Rigidbody>().drag = superDrag;
if (Mathf.Abs(turn) > 0.01)
{
if (GetComponent.<Rigidbody>().angularVelocity.sqrMagnitude > sqrdAngularSpeedThresholdForDrag)
GetComponent.<Rigidbody>().angularDrag = fastADrag;
else
GetComponent.<Rigidbody>().angularDrag = slowADrag;
}
else
GetComponent.<Rigidbody>().angularDrag = superADrag;
transform.position = Vector3.Lerp(transform.position, new Vector3(transform.position.x, hoverHeight, transform.position.z), hoverHeightStrictness);
var amountToBank : float = GetComponent.<Rigidbody>().angularVelocity.y * bankAmount;
bank = Mathf.Lerp(bank, amountToBank, bankSpeed);
var rotation : Vector3 = transform.rotation.eulerAngles;
rotation *= Mathf.Deg2Rad;
rotation.x = 0;
rotation.z = 0;
rotation += bankAxis * bank;
rotation *= Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(rotation);
}
// thrust
private var thrust : float = 0;
private var turn : float = 0;
function Thrust( t : float )
{
thrust = Mathf.Clamp( t, -1.0, 1.0 );
}
function Turn(t : float)
{
turn = Mathf.Clamp( t, -1.0, 1.0 ) * turnSpeed;
}
private var thrustGlowOn : boolean = false;
function Update ()
{
var theThrust : float = thrust;
if (playerControl)
{
thrust = Input.GetAxis("Vertical");
turn = Input.GetAxis("Horizontal") * turnSpeed;
}
if (thrust > 0.0)
{
theThrust *= forwardThrust;
if (!thrustGlowOn)
{
thrustGlowOn = !thrustGlowOn;
BroadcastMessage("SetThrustGlow", thrustGlowOn, SendMessageOptions.DontRequireReceiver);
}
}
else
{
theThrust *= backwardThrust;
if (thrustGlowOn)
{
thrustGlowOn = !thrustGlowOn;
BroadcastMessage("SetThrustGlow", thrustGlowOn, SendMessageOptions.DontRequireReceiver);
}
}
GetComponent.<Rigidbody>().AddRelativeTorque(Vector3.up * turn * Time.deltaTime);
GetComponent.<Rigidbody>().AddRelativeForce(forwardDirection * theThrust * Time.deltaTime);
}
//ïî ñîáûòèþ òðèãåð ïðîèñõîäÿùåìó íà ìàøèíå îáúÿâëÿåì ãëîáàëüíóþ ïåðåìåííóþ
// ñîìåð è ïðèäàåì ìàøèíå òàã ÌÌÌ ýòî äëÿ ñëó÷àÿ ðàçìíîæåíèÿ ìàøèí îá÷íûì êëîíèðîâàíèåì
var btarget : Transform;
function OnTriggerEnter (other : Collider) {
//var bbc : Transform;
//name = "Racer Car1";
btarget.position = transform.position;
somer=2;
gameObject.tag = "Player";
}
function OnTriggerExit (other : Collider) {
if (gameObject.tag == "MMM")
gameObject.tag = "MMM";
if (gameObject.tag == "Player")
gameObject.tag = "Respawn";
somer=0;
}
function Update () {
GetComponent.<Rigidbody>().drag = 0;
//ìàøèíà çàïóñêàåòñÿ ïðè íàæàòèè enter. äëÿ ýòîãî ñîáëþäàþòñÿ 2 óñëîâèÿ íàæàòèå ìûøêè
// è íàõîæäåííèè ÷åëîâåêà â îáëàñòè òðèãåðà . îá ýòîì ïåðåìåííàÿ ñîìåð.
//ïðè ýòîì óñëîâèè âêëþ÷àåì ñêðèïò ïëååð êàð ðàíåå îòêëþ÷åíûé â èíñïåêòîðå
//è ïðè óñëîâèè ÷òî âêëþ÷åí îáúåêò ñ òàãîì ÌÌÌ
//btarget.position = transform.position + Vector3(10,10,10);
//btarget = Vector3(100,100,100);
if (gameObject.tag== "Player"){
//ïðè íàæàòèè åíòåð
if (Input.GetKeyDown ("return")&& (somer==2)&& GetComponent (BoatScript)){
gameObject.tag = "MMM";
// âêëþ÷àåì ñêðèïò êàð ðàíåå îòêëþ÷åíûé â èíñïåêòîðå
GetComponent (BoatScript).enabled=true ;
//îòêëþ÷àåì êîíòðîëåð ó ÷åëîâåêà
var go = GameObject.Find("First1");
go.GetComponent(FPSInputController).enabled = false;
// îòêëþ÷àåì êàìåðó ó ÷åëîâåêà
var go1 = GameObject.Find("Camera1");
go1.GetComponent(Camera).enabled = false;
}
}
if (Input.GetKeyDown ("space") &&(gameObject.tag== "MMM")){
// ïåðåìåùàåì
var go21 = GameObject.Find("First1");
go21.transform.position=transform.position + Vector3(6,2,0);
// îòêëþ÷àåì ñêðèïò êàð
GetComponent (BoatScript).enabled=false ;
var go221 = GameObject.Find("Camera1");
go221.GetComponent(Camera).enabled = true;
// btarget.position=transform.position + Vector3(0.1,0,0);
GetComponent.<Rigidbody>().drag = GetComponent.<Rigidbody>().velocity.magnitude / 00;
// name = "Racer Car";
somer=0;
gameObject.tag = "Finish";
}
}
I was trying to use these how do I??