0 votes

I want to create enemy that just to Player position. It should be simular to enemies from Ori. https://youtu.be/Wh6gBjfXKxw?t=679 . What is the posible ways to implement this. RigidBody or Kinematic. I don't need exect code but explanation witch approach to choose for implementing this.

Godot version 3.4.2
in Engine by (16 points)

1 Answer

0 votes

Wow, Ori is such a pretty game. Such respect to the devs.

This bit at least is easily done. So, you need some kind of enemy AI to decide when they are going to leap. I'll put that aside as a separate topic but really it could be as simple as setting a timer with a random value or distance triggering it. AI doesn't always need to be complicated, it's just agency.

Ok, so let's say you've got a _timeout() method which has just fired meaning your enemy should jump where the player is at that moment. So, you need a reference to the player. So, maybe when the enemy first spawns it loads the player object as a member variable. I'm going to assume you know how to do that. If not, just ask.

So, now in the firing function we can just grab player.position and we've got self.position, the enemy that is. Ok, now there are roughly six hundred and thirty two ways to do the jumping...

Let's say we decide to use a Tween and the enemy is a kinematic body. So, we cover the x and y moving the enemy up and down. A cubic interpolation, ease in and out, would work really well. There are loads of tutorials on YT on Tween and the docs cover it nicely.

Like I say, this is one solution out of countless possibilities but my guess is it's what Ori did. I'm not certain though but it would certainly work even if they used a different tactic.

If you put together a project, have a stab at the code and it doesn't work. Feel free to ask here and post your code.

by (2,156 points)
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.