How do I get enemy to run away from player ?

0 favourites
  • 15 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • hello everyone ,

    I am struggling a bit to create this behaviour , i am currenltly using the behaviour "move to" and "line of sight "to move both the player and the enemy away , but it does not work like i want .

    i want the ennemy to move to the opposite of the player, plus if it touche the edge of the layout to move away from the edges.

    Thanks for your help

  • normalize the vector from player to enemy

  • Thanks for your reply .

    Sorry if this a dumb question , but can please you explain to me what do you mean by that ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • so like when you normalize a vector between two points (player and enemy) you get a value for X and a value for Y and X+Y = 1 dont ask me how or why im a dummy but by using that you can give the character a target move to position relative to away fro mthe player where u multiply the distance of 1 to the distance you want because X and Y = 1 so it will be the correct distance and the correct angle and u can make it walk good so it'S awesome and u get correct X and Y positions to move to

  • Thanks a lot for explications .

    Still trying to wrap my head around , iam quite the dummy myself .

    So i should the use distance(player.X,player.Y,ennemy.X,Ennemy.Y) to get the distance ?

    Again thanks for the answers .

  • basically if you want the enemy to be 100 units away from the player, u normalize the vector between them, and u will get like, for example, x = 0.7 and y = 0.3

    0.7 + 0.3 = 1

    you want the enemy to be 100 units away

    x = 0.7 x 100

    y = 0.3 x 100

    or something like that and it will move away from u like magic.

    to get X and y you do like (player.x + enemy.y) / distance(thingsgohere) and same for Y and u get ur two x and y to multiply the distance by or whatever

    I think that'S how it works ???? and u get ur target move to location

  • Thanks you

    I think i understand , i will test it and see .

    Thanks for your answers .

  • Hello again everyone,

    So i guess a got the general idea(Still strugling with the math aspect) not working

    here what i went with but it still not working.

  • try figuring out where it fails! Debugging skills !! is it moveto? spawn a sprite and set it'S position to the move to target on every tick, see what happens !!!

  • I managed to figure it with a lot of help from other people .

    i got the result i want using this

    Thanks for your help

  • bites you

    bites you

    bites you

    lets out a howl

    time stops

    glows in red energy that makes my clothes and air whip like there are strong winds but my energy is the source

    my left eye glows menacingly and i grin and grow 3 meters tall

    tears you apart in a cool combo attack too quickly for anyone to follow my movements (with my awesome claws painted sparkly white but with blue flakies like a jawbreaker)

    I stop in a cool pose and my aura dissipates and time resumes and u explode and paint the walls and ceilings red

    i swing both my arm down in a cool X fashion and the blood soaking my nails leaves marks on the floor and they are pristine again

    I whisper under my breath "not this again, we were supposed to work through this together and learn something" as i turn around and leave and the camera swings around to show what'S left of you in the middle of the screen and my back as i dramatically walk away

    I toss this over my shoulder on whatever'S left of you without looking back

    drive.google.com/file/d/1Yfbx0QHtl1MOxUkfg_kuN04Zuzi--rmN/view

  • That last post reads like something out of a Clive Barker novel, but not as well written :)

  • Hahaha XD. Even better, some artwork to accompany the story :)

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