Enemy follow player without rotating?

0 favourites
From the Asset Store
Simple resize and rotate events for any sprite, quick and easy event sheet that you can use for your own projects.
  • I'm creating a top-down rpg, and I'm trying to figure out how to do a couple things with the enemy:

    1. I'd like the enemy when > X amount of pixels away from the player to sine randomly horizontally AND vertically (similar to the old final fantasy npcs)

    2. Once I'm close enough to the enemy (< X amount of pixels), I'd like the enemy to follow the player WITHOUT rotating, but still changing the animation based on angle (ie. if I'm below the enemy, the enemy is playing a facing down animation; if I am to the right of the enemy, the enemy is playing the facing right animation)

    Can anyone please help with this? I can only seem to make the enemy follow me while rotating which looks ridiculous in an rpg :).

    Thanks in advance!

    Steve

  • Create a enemy_node sprite - set it to hidden.

    Make it follow the player.

    Pin the enemy monster sprite to it.. the pin behaviour can be set to position only..

    hope that helps :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey Matt,

    Thanks for the response. I figured out another way to do - basically:

    System Event (if Distance(Player.X,Player.Y,BadGuy.X,BadGuy.Y) < 900

    Move (2) Pixels at angle Angle(BadGuy.X, BadGuy.Y, Player.X, Player.Y).

    Now my only issue is making it so if the badguy is moving between x angle and x angle, play "X" animation. But for some reason it doesn't seem to work.

    Anyone know how to change the enemy's animation based on it's movement?

    Thanks!

    Steve

  • Sorry to bump, but has anyone been able to figure this out? I can't find an appropriate answer anywhere in the forums.

    Thanks,

    Steve

  • Would something like this work for you:

    for each badguy

    badguy.angle > x

    badguy.angle < y

    .. set animation to z

    Repeat for each animation.

  • Hey Vee,

    Could you maybe expand a little more on what you mean?

    Based on what you said, I did something similar which works, just not as well as I'd like it to:

    IF

    System Event (compare variables) - Player.X < BadGuy.X

    System Event (compare variables) - Player.Y < BadGuy.Y

    THEN

    Set BadGuy animation to "WalkLeft"

    Basically saying if the character is to the left of the BadGuy and above the BadGuy, the animation will play WalkLeft. While this kind of works, the animations change on diagonal increments.

    Let me know if you meant something else?

    Thanks,

    Steve

  • Thats a bit different principle, my idea is to just set the animation based on badguys angle. Posting a .capx of your problem would help a lot :)

  • stevemazzaro.com/CAPXTest.zip

    Here's the capx. The section you're looking at is in the Enemies group folder (1st couple of events)

    Thanks!

    Steve

  • Link didn't work for me. :)

  • stevemazzaro.com/CAPXTest.zip

    Sorry try this.

  • stevemazzaro.com/CAPXTest.zip

    Sorry try this.

    I did not see a clear problem with this .capx, could you describe a bit more what you wish to achieve? Is there some specific way of moving you are looking for or do you wish to simplify your events?

    Nice visuals by the way :)

  • Thanks :).

    This is basically what I'm trying to achieve:

    <img src="http://stevemazzaro.com/Example.png" border="0" />

    When the player enters one of the "WalkX" groups in the image, the BadGuy plays the "WalkX" animation. Right now it's doing this, but at a 0, 90, 180, & 270 degree setup. However, when I try setting what I currently have to "is between angle XY + XY", it still doesn't work.

    It's almost as if even while moving, the BadGuy's angle parameter is never actually set.

  • Gotcha, this should be what you are looking for:

    Enemy angle example

    It's not as simple as I wished, probably someone can come up with solution that doesn't need the extra angle conversions and stuff.

    And you are correct, when moving the badguys angle parameter is actually never set, it is only set when you rotate the sprite. So angle is 0 all the time, changing animations doesn't change the angle of the sprite itself. In this sort of movement we don't really need to set the angle to anything else anyway. :)

  • Hey Vee,

    I can't seem to open this - it says somehow that you're on version 118, while I'm on version 114. I purchased this off steam, so in theory it should always be up to date?

    Any chance it's short enough you can just upload an image?

    Thanks so much!

    Steve

  • Here you go:

    <img src="http://dl.dropbox.com/u/19921470/AnimationByAngle.PNG" border="0">

    You can also opt in for beta updates in steam if you wish, you can find instructions in this blog post.

    List of most recent releases can also be found/downloaded here!

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