Freddy33's Forum Posts

  • also what is distance> player.x and distance<player.x? is that the zombies X?

    I thought that ws needed to set the player distance?

    I am really struggling to with the animations, if I try to make th player stop with the width animation, it kindda messes up the other animations. I might have to go back to basics here and learn about switching animations.

    Thanks corp

  • condition

    compare two variables,

    distance(zombie.x,zombie.y,player.x,player.y) >= 70

    sub event 1 condition

    if zombie.x < player.x

    action1 zombie set not mirrored

    action2 zombie set x to self.x+5

    sub event 2 condition

    if zombie.x > player.x

    action 1 zombie set mirrored

    action 2 zombie set x to self.x-5

    that's it.

    if you want to limit where the zombie stops,

    you just compare the

    if zombie.x > player.x + zombie.width*2

    respectively

    if zombie.x < player.x - zombie.width*2

    the 2nd option would make the zombie stop at a distance from player of around zombie.width*2 or if your zombie width is 35 pixels then it will stop at 70 pixels distance from the player.x which is given by the player origin point so if your player has the origin point in middle then it will calculate from that, if your player origin point is to left or right you will face a bit of problems visually, cause logically its still 70pixels distance.

    Thank you Corp,Plinkie and Davy. Appreciate all the help. Worked perfect and the code looks a lot cleaner.

    I should be able to work out the rest.

    But what is this? self.x-5. The zombies self minus 5 pixels on the horizontal? Not sure why this works.

    Thanks again. :-)

  • Hello,

    Have you tried line of sight, you could then have the zombie turn to the player and attack.

    Yeah I took LOS away because I think it was causing problems.

    Is there an option for left and right?

    I am just going to try corpstudio events and see how that goes. Not sure why I am struggling so much.

  • Hi Bud,

    Thank you for explaining that. So it kinda of acts similar to a variable.I am dreading get into the math part of construct. But I am learning from you tube and you guys!

    Cheers corp!

  • Hi both, I am not sure. I have a variable of distance set up. And I think I have tired about 1000 variations of events with no joy.

    Basically the zombie starts left of the player. When the player gets within a certain range (600 pixels) The zombies moves from idle to walk. This is ok, its working well - Cap attached.

    But, If the player is to the right of the zombie, I am finding it nearly impossible to get the zombie to follow the player. Setting the player not mirrored wont work, because if the player turns hes going to mirrored non mirrored.

    I dont know?

  • One way is:

    Check the distance int(distance(player.x,playery,zombie.x,zombie.y)). if it's less than 70, then you can do:

    if the player.X is > than the zombie.X

    - simulate control right

    if the player X is < than the zombie.X

    - simulate control left

    Hi buddy, not sure why its not working, the events look ok?

  • Thanks Ribis.

    So I set that event first as a condition?

    Is that an interger?

  • Cheers plinkie/bad Mario.

    But why does that piece of code work. What and how is it doing exactly?

    Sorry to be a laymen. Also why is not player.x, player .y? Why player.x, player.x?

    Thanks

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello, Thanks for the help with this one. I have been at this for hours and getting really fed up with it.

    Basically, when the player is 70 pixels or further, I want the zombie to walk to the player. Also when the player is to the right of the zombie, I want the zombie to walk to him.

    I have an issue with the whole event,i have done something similar on a training game before and it worked. But not this time. The first capx is the game in question. The second cap was the game where it actually worked.

    I have no clue what I am doing and trial and error is not working. I think this a knowledge gap or inexperience with events. Any help would be appreciated. Enemy AI is going to be a big part of the game, so I want to be doing things right in the first instance.

    Ta

  • Hello, Thanks for the help with this one. I have been at this for hours and getting really fed up with it.

    Basically, when the player is 70 pixels or further, I want the zombie to walk to the player. Also when the player is to the right of the zombie, I want the zombie to walk to him.

    I have an issue with the whole event,i have done something similar on a training game before and it worked. But not this time. The first capx is the game in question. The second cap was the game where it actually worked.

    I have no clue what I am doing and trial and error is not working. I think this a knowledge gap or inexperience with events. Any help would be appreciated. Enemy AI is going to be a big part of the game, so I want to be doing things right in the first instance.

    Ta

  • Hello, I got this code from you tube. I have also seen it on here somewhere. Whats the point in it? The enemy seems to behave the same, even without this event.

    Also what is state? I know what Boolean and the number variable does. With state you can write in a box, but it dosent seem to do anything if I write idle or run ect?

    Thanks for the help.

  • id go with statements or variables/booleans or in C2 way when something happens, switch a variable to some value different than 0 then if that variable is not 0 play surtain animation.

    Hi Buddy,

    Ok, I have worked it out. Not sure if its the best way to do this, but it seems to work well..

    Any thoughts?

    ta

  • Hi Buddy,

    Happy new year! Well you never know, Elon musk is making progress. Although a flying hoverBoard would do me!

    Thanks for the advice, I had a feeling I would run into this problem again. Shooting wont work, unless i disable the top three, I have tried for about an hour to get it to work, but I think this is a knowledge gap. Any ideas?

    Thanks for the help!

  • Hello and happy new year.

    My main player will have about 8 or 9 animations, like idle, run, shoot, jump, roll, etc.

    From my experience, using events alone can sometimes cause problems. Should I use states or variables for each animation?

    You see, the player will be performing these animations frequently, so every thing needs to be smooth. Any direction will help me decide the best way and I should be able to put it all together.

    Many thanks

  • Thanks buddy,

    sorry for the late reply. I see, that's actually really handy (the parameter part. I think I have been avoiding funtions so I am going to spend a day and create a simple game where I can practice with functions and get a full understanding of how and where to use them in the event sheet)

    Offset parmeter i see alot in the kiwi game, like if player is against wall, set offset to x-32, y, -122. I assume its just used as position for the player.

    Thanks mate, have a fab new year :-)