How can the enemy jump to the player

I want to make an endless runner game. A runner game in american football style I made 5 lanes. The enemies are moving towards you. I’ve different power-ups and different enemies. I have a normal enemy, giant enemy and a jumping enemy. I need some help with the jumping enemy. The jumping enemy is a normal enemy who moves straight forward but when the enemy is near the player then he moves to the player’s lane. Basically the enemy need to move to the lane of the player when the enemy is close. [33344-ss+(2014-10-06+at+11.18.50).png|33344]

Can you help me please with a c# script?

No. The FAQ states that UA is NOT for asking for scripts. You should also provide some sample code so others can see how your game works in regards to the question at hand.

What have you tried so far?

To get your started anyway, here’s one way to do it:

In the enemy’s Update(), check how far he is from the player (Vector3.distance).
If the distance is below a certain threshold, call a function that make him jump to the player’s land. How you do this is up to you, you could use Vector3.lerp and make the atual up and down movement of the jump part of the animation, or use transform.position to update the position every frame along a ballistic curve which you would have to compute with a mathematical formula. There are a lot of resources for this on the web freely available.

To make things short: Use the information above, research, try, and if you have any questions after that or any errors occur you can’t figure out yourself, provide all relevant information (but no pages of scripts), and see if you can be helped with that.

Best of luck so far :slight_smile:

I’m not gonna write out code or anything, I’m tired.

Just do this, put a Trigger on your player, if he gets within a certain distancce, make your enemies have a rigidbody (of course)

and apply a AddRelativeForce in the Vector3.up position at a speed of your liking, also changing mass and stuff on rigidbodys help (start with higher numbers for force) as I’ve found out that using like a force of 50 does absolutely nothing unless u have virtually no mass lol.