JHunter's Recent Forum Activity

  • > Well, I figured out the issue with it not working past 4, instead of up to 8 you need to go 0-4 then -1 through -4. However, can you still explain to me the most efficient way at layer these events? Be is per tick, or... How?

    >

    > Thank you by the way guys for the help so far

    >

    Sorry for that, I wasn't aware the angle(x1,y1,x2,y2) gave negative values..

    If you have more than 1 enemy, I guess this would do:

    for each enemy

    distance(enemy.x,enemy.y,player.x,player.y) < 100

    -- instance variable = 0

    > set animation ...

    --instance variable = 1

    > set animation ...

    where -- are subevents..

    It all works! Thank you so much. Unless you have a better idea to handle sprites facing the players object, that will be all!

  • Well, I figured out the issue with it not working past 4, instead of up to 8 you need to go 0-4 then -1 through -4. However, can you still explain to me the most efficient way at layer these events? Be is per tick, or... How?

    Thank you by the way guys for the help so far

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • >

    > > There are many ways to go about it but... for the most basic way:

    > >

    > > What I would do is get the angle from the npc to the player.

    > >

    > > You can then set the npc frame to round(angle/45). Set frame 0 to be facing east, frame 1 to be facing south east and so on.

    > >

    > > Does this make any sense?

    > >

    >

    > Quick code insight, range is a circle sprite pinned to my player object. I use it to detect range as line of sight is useless ^_^

    >

    > Here is what I have done http://i.imgur.com/q9AVqRr.png and honestly it is the only way I can think of to actually get this to work. I'm useless when it comes to angles honestly. It works until I added in the part about playing animations, it will not play the animations in the section I highlighted in red... Also if I add in another enemy object only one of them will update. I will need it to update with multiple...

    >

    > Can anyone offer insight please? Or perhaps tell me what I am doing wrong.. Any help is greatly appreciated.

    >

    > Thanks in advance!

    >

    Ruskul gave you a great answer..

    set a variable on your enemy to round(angle(enemy.x,enemy.y,player.x,player.y)/45)

    if this variable is 0 or 8 set animation to east

    1 = southeast

    2 = south

    and so on..

    instead of your detection sprite you could check the distance between your enemy and player with distance(enemy.x,enemy.y,player.x,player.y)

    I didn't know it was an answer to my problem. But I have a couple questions, again I am new sorry. I set a variable to round(angle(enemy.x,enemy.y,player.x,player.y)/45) but how exactly do I set the rest up? Do I use:

    Each Tick:

    use distance(enemy.x,enemy.y,player.x,player.y) to determine distance

    If within distance use round(angle(enemy.x,enemy.y,player.x,player.y)/45) to get the angle

    then a big if statement with all the individual possible outcomes?

    I have also run into the same problem as before, NE, N, NW do not work

  • There are many ways to go about it but... for the most basic way:

    What I would do is get the angle from the npc to the player.

    You can then set the npc frame to round(angle/45). Set frame 0 to be facing east, frame 1 to be facing south east and so on.

    Does this make any sense?

    Quick code insight, range is a circle sprite pinned to my player object. I use it to detect range as line of sight is useless ^_^

    Here is what I have done http://i.imgur.com/q9AVqRr.png and honestly it is the only way I can think of to actually get this to work. I'm useless when it comes to angles honestly. It works until I added in the part about playing animations, it will not play the animations in the section I highlighted in red... Also if I add in another enemy object only one of them will update. I will need it to update with multiple...

    Can anyone offer insight please? Or perhaps tell me what I am doing wrong.. Any help is greatly appreciated.

    Thanks in advance!

  • I need help with code. Basically, I want to be able to walk my player around a NPC and have the NPC's frame switch to match where my player is walking.

    For Example: Player moves to the Right of NPC, NPC's frame switches to the picture of the NPC facing right.

    I have pictures of the NPC facing in the 8 directions. N, NE, E, SE, S, SW, W, NW. I have messed around with angles, and the clockwise code but I just cannot get it to work. I thought I would ask the community as I am sure someone knows how to get this to work.

    Thanks in advance!

  • I'm not sure if bumping is allowed.. But it's been a day and a bit. Does anyone know?

  • I've done so much learning today, getting a developer account, learning phonegap build, figuring out how to get a keystore thingy whatcha call it... now IAP, the one thing that has stumped me today. All the forum posts I read are talking about Cocoon which isn't used here anymore, and the basic tutorial here https://www.scirra.com/manual/173/iap is good and all but useless when it comes to actually doing much.

    I did exactly what it said, I put the things at layout start, I tried infusing things with buttons, I have my product and developer account set up, I just.. I can't

    All I am trying to do is set up a couple in-app purchases. I understand how the "Has product" stuff works to detect if the user has purchased said items and how I am going to incorporate that into my existing code. I just have no idea how to get the store to pop-up and be like "Hey buy this!"

    Thanks in advance for any replies. Let me know if you need more info

JHunter's avatar

JHunter

Member since 30 Jul, 2015

None one is following JHunter yet!

Trophy Case

  • 9-Year Club
  • Coach One of your tutorials has over 1,000 readers

Progress

10/44
How to earn trophies