Stop spawning by the car when I click a a key

Everything works as intended except for when I’m not by the car and I click “Z” it still spawns by the car and I want to stop that. Just don’t know how or what to add.

It seems like your first event doesn’t do anything.

I think the problem is with the third event.

I think if you remove the change position action in the third event the problem will be solved.

hello! not sure what you mean by: “spawns by the car”
are you saying that your player still enters the car even if you are not close to it?


your last event has only Z key pressed to activate. Which means that it will teleport your player to the blue car every time you press Z no matter where you player is or any other things basically (even if you are not inside the car)

make sure that you store the information “is player in the car? yes/no” somewere in your game. you could add a “boolean” scene variable. or, in your case… check if player X = -999999


i would suggest that instead of moving your player at position -999999, you would make it zero opacity instead. Either that or you delete player object, and respawn it as you exit the car (assuming no object variable were important inside “player”)

You’re right. I think removing the position change action is enough.

Also, your idea of ​​making the player transparency 0 is great.

Thank you guys, I will try that now.

Hi I think I almost got it I’m just stuck on the boolean part of the variable and I don’t know what to put.

Remove the boolean and see if it works properly.

In addition, you need to change the state of the booleans in the actions.

However, I think it would work without booleans.

I tested it without the booleans earlier and everything was working. The main problem I have is when I click “Z” even if I’m not by the car and running around it instantly teleports me back to the car.

In that event, remove the position change action.

Oh wow thank you so much, surprisingly it just worked by removing the position like you said

Here is the code if anyone wants to see. The camera needs a bit fixing but I can do that part myself I think.Thank you.

I’m glad I could help.

Wait a minute. When you get out of the car, you spawn at the same place you got in. To fix this, create a boolean variable. Set it to true on the first event and false on the second event.

When the boolean variable is true, change the player’s position to the car’s position.