0 votes

I'm trying to make my first game on godot, so I'm very inexperienced. It is a platformer. I'm following an old tutorial, where the set.trigger function was still present. Now, what should I use instead of it? The target is to make the player fall down when he touches the enemy. I created an area 2d with its collision shape, child of the player node, then in this 2d area I created the body entered signal connected with player. This would be the code:

func onArea2D2bodyentered(body):
if not alive: return
dying()

func dying():
if not alive: return
alive = false
velocity.y = -500
getnode("Area2D2/CollisionShape2D").settrigger(true)

Could anyone help me? Thanks a lot

in Engine by (12 points)

1 Answer

0 votes

is trigger just a property of your Collision Shape ?
if yes, You can set it any of these ways :

get_node("Area2D2/CollisionShape2D").trigger = true

or

get_node("Area2D2/CollisionShape2D").set("trigger",true)
by (8,101 points)

Yes, but it no longer exists. It was used so that the player would not collide anymore but simply fell down. I tried like this:

$Area2D2/CollisionShape2D.set_deferred("disabled", true)

But the player still collides at first and he still doesn't fall down

There is still plenty of options to disable collision. You can remove or change collision mask and layers, You can disconnect area entered signal, But the simplest is to set monitoring property of area to false

Yes okay. Now the problem is making him fall down when he touches the enemy To do this I was thinking of using an animation. But what x and y values should I set to make he fall vertically where he touches the enemy? Because earlier I created an animation for the coins, i.e. when the player touches them, they go up and disappear, but the coins stay still.... Excuse me if I ask you some questions that may seem simple to you but as I told you it's my first game... In the animation player is it possible to use the key only for the y value of the position and not both x and y?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.