x


Enter car problem Character grows And have to hold the button?

var player: Transform;
var Jeep: Transform;
var PlayerCamera: Transform;
var JeepCamera: Transform;

function Update (){


if(Input.GetKey("v"))

InCar = 0;
player.GetComponent(CameraMouse).enabled = true;
player.GetComponent(FPSWalker4).enabled = true;
PlayerCamera.GetComponent(Camera).enabled = true;
PlayerCamera.GetComponent(AudioListener).enabled = true;
player.transform.parent = null;
Jeep.GetComponent(CAR).enabled = false;
JeepCamera.GetComponent(Camera).enabled = false;
JeepCamera.GetComponent(AudioListener).enabled = false;

if(Input.GetKey("e"))
{
InCar = 1;
player.GetComponent(CameraMouse).enabled = false;
player.GetComponent(FPSWalker4).enabled = false;
PlayerCamera.GetComponent(Camera).enabled = false;
PlayerCamera.GetComponent(AudioListener).enabled = false;
player.transform.parent = Jeep;
player.transform.localPosition = Vector3(-0.3,3,.3);
Jeep.GetComponent(CAR).enabled = true;
JeepCamera.GetComponent(Camera).enabled = true;
JeepCamera.GetComponent(AudioListener).enabled = true;
}
}

I know there are lots of enter car posts but i haven't seen any that answer this question. When i press "e" i will transform to my position, but i have to hold it to stay there, and when i stay there most of the time, not all the time just most, the player will start Growing, sometime realllly fast and crash the game other time it happens slowly or not at all?

more ▼

asked May 07 '11 at 10:41 PM

BrettRiet gravatar image

BrettRiet
49 12 12 19

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Might be better off turning these each into a function of their own. Then in the update function, check the input key as usual, and then also check the current incar state.

more ▼

answered May 08 '11 at 03:16 PM

burgunfaust gravatar image

burgunfaust
260 5 7 17

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5088
x1281
x418
x58

asked: May 07 '11 at 10:41 PM

Seen: 712 times

Last Updated: Jul 05 '12 at 11:17 PM