So, im making a car script. Now everything works fine, except one little thing, when i leave the car i want to spawn above my car. So ofcourse i could just do transform.position = new Vector3(transform.position.x, transform.position.y + 5, transform.position.z);
BUT, that would freeze the player. I know of Transform.translate, but i dont want to use it. Are there any way i could set the players position like just setting it to a transform, without freezing it? I mean, if i wanted to i could just instantiate a new player at the position of my spawn transform, and i could carry the player stats over, but i want to know if there any way to fix this. Thanks.
hi there,
are you meaning that the this is a recursive statement, in that you are constantly setting the player to be +5 units on the Y axis from the car? is that what your meaning by freezing? is the animations freezing up also, or just the transform component?
you could always just set a bool to flag ifExitingCar so you can run the positional settings once, and then use something like
-Pseudo code of the top o my head-
(ifExitingCar)
{
player.transform = spawnPos.transform;
ifExitingCar = false;
}
then you can change that bool flag on the exit car function if you have one, so that it will only transform player once when exiting car.
apologies if i’ve for the wrong end of the stick there
edit sorry just an afterthought, the players collider isnt penetrating the car and stopping it by any chance?