How do I make this certain enemy for my game?

0 favourites
  • 9 posts
From the Asset Store
Pixel Enemies for SHMUP consists of 45 enemy ship sprites to be used in your game.
  • Hello! The problem I encounter in my game is how to make this enemy. Now the enemy is an alligator, and I want it when in a certain range of the player jump up and pounce on the player. The problem is I don't know how code this into the game, it would also be very beneficial if you also helped me with the animation between the walk and pounce. When Alligator is a certain distance from the player, Alligator stop walking animation, start pounce animation, and jump on player. I already know how to code health for the player.

    Thank you for your time!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • you could do the line of sight behavior to check if the player is in range.

    You could also use the physics action, apply force at angle and the platform behavior for the jump mechanic. You should make sure that your physics behavior is set to prevent rotations though.

  • Thank you! This was incredibly useful I got the movement working the way I like it thanks to you! But I still encountered one more issue, um I tried to make the animation work, but I'm still having trouble with the alligator knowing that when it's line of sight is on the player it should start attack animation, and when it doesn't have line of sight it does walk animation. For some reason it won't work.

    Thank you for your time!

  • Yeah, so you can do this by using the (has LOS to object) event. Do something like,

    If Alligator has LOS to Player

    Alligator stop animation walk

    >>> Alligator set speed to 0

    >>> Alligator set animation to Attack

    If Alligator Not has LOS to Player

    >>> Alligator set animation to walk

    >>> Alligator set speed to (speed value)

    You can invert (use the not command) by right clicking a condition on an event and selecting the X.

    Hope that helps!

  • Do you see this?

  • Oh-wait you can. Okay so um, I pretty sure you know what you're doing and I probably did something wrong but, the code I copied didn't exactly do what you said unfortunately. In the code, Duckiosious is the Alligator, and the dino is the player. Lines 41, 42, 43 is the code I added from you, and lines 37, 38, 39, and 40 is the tracking mechanism on how the duckiosious/alligator moves. Did I do something wrong?

    Thank you for your time!

  • When the problem happens, is it that the alligator never stops playing the walk animation? In your code, you have it so that if walk is true or false, the alligator will still play the walk animation. Its your system boolean comparison on line 40 and 41. I would put this code in the statements above. That's your problem because the animation is constantly being set to walk.

  • Oh my gosh! Thank you so much! I know my problems with this game may sound dumb or easy to fix, but truly to me you are a miracle. I wouldn't in the world have figured out how to do this! Thank you so much and have a great day!

    Thank you for your time!

  • No problem

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)