Creating Jumping enemies from Mega Man

At 0:18 of this video, you can see pink jumping enemies.
They can’t walk. They jump toward players current position.

Here’s what I currently have. I created a behavior:

I need help with the “add force” part. What formula should I use in the “angle” or/and “force length” (aka. speed) so the enemy feels intelligent enough?

Thanks.

Edit: I found this: Platformer. The enemy jumps on the player
Looking into it

You sussed it yourself, well done :slight_smile:

Not necessarily…
but I’ll try

If you do figure it out, how do I do the same thing in reverse, have the player jump on an enemy?

That would be a completely different scenario. You can just control the player.

There are multiple tutorials on that.
Here’s one

1 Like

I’ve not been able to come up with any good ideas.
I might want to give PlatformerObject behavior to the enemy, but I still don’t know how to make it jump towards players position.

Help?

Giving the enemy Platformer Character behaviour will simplify things quite a bit.

What you’ll want to do is check if the enemy is on the platform, in which case jump. If the enemy is jumping and the player’s x position is less than the enemy’s x position, move left. If it’s jumping and the player’s x position is greater than the enemy’s x position, move right.

Something like:

1 Like

Yes, but this is creates a more simplified result than I wanted. I’ll do this if nothing else works.

I want the enemy to not change direction after it leaves the ground. It can’t influence it’s direction after it is in the air.

Also, I’d like the enemy to vary the jump angle/strength depending on the distance between it and the player. If the player is close, smaller jump is required in order to not jump OVER them.

Then add a variable on the enemy object to indicate which direction it’s jumping. Set this variable when it jumps and check the variable instead of checking its relative position when moving left or right.


As in lower height, or shorter distance? If jump height, then change then change the enemy’s jump speed. If the distance jumped, then modify the maximum horizontal speed when the jumping. Something like:

The abs function takes the absolute value of a number - it removed the negative sign if the numebr is less than 0.

The clamp function will take a number and keep it within the range you give it. In this case, if the number is less than 25 it’ll get set to 25, and if it’s greater than 250 it is set to 250.

I just want the enemy to jump on the player.

If the player is very far away, the enemy does the maximum jump and closes as much distance as it can.

But if the player is very close, the enemy will do a smaller jump in order to avoid jumping over them. A smaller jump in this sense can be achieved both by lowering the jump speed (jump power) or by changing the jump angle towards north (the jump arc of the enemy is higher, but it will move a shorter distance on the x-axis).

I’ll read your message more thoroughly tomorrow and test things out. Thanks for the help.

It seems to me that you want the enemy to travel in a parabolic path and land where the player was at the time of the jump?

I never studied physics so I can’t really help, but the Platformer jump evaluator game example may help you figure out how to calculate this.

1 Like

Yeah I have seen that “demo”. I have hard time understanding it.
Thanks a lot though