How to stop my object when I collide with another object?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Nanogines

My current game is a runner platformer where my player is automatically set to move. I’ve added another object that functions like a lift. But here the problem arrives that whenever I jump on the lift, my player continues moving and does not stop on the lift. I want the player to stop when I’m on the lift. How can I do that?

Create an area around the lift and connect the body_entered signal and use that to stop the player from moving.

Magso | 2019-07-09 16:05

:bust_in_silhouette: Reply From: Marre

You could make an Area2D node that detects if the player is on the lift. And if the player is on the lift you can set his movment to 0. To do this you would:

  1. Create a Area2D
  2. Create a CollisionShape2D under the Area2D ndoe, so that the Area2D node is the parent.
  3. Now click on the CollisionShape2D node and look at the inspector. Now look under “Shape” and choose a Shape.
  4. Now adjust the shape of the collision to where you want the player to be detected.
  5. Now press the to Area2D then Node then Signals, and choose body entered
  6. You will get a popup window, press the player node.
  7. You will now get the player script infront of you, now under the function that was created you will set the player movment speed to 0.