Taweel's Recent Forum Activity

  • Hello All,

    I have two sprites (red and blue).

    I start with 3 red sprites on the layout. When I click on a red sprite, I want it destroyed and a blue sprite to be spawned in its place and vice versa. I tried the following:

    But I end up with all blue sprites. Once they are blue, they never go back to red. If I change the order of events, the opposite happens.

    I am assuming that the "touch" event is being triggered for the newly spawned object. I am right? Is there a way to prevent that?

    Many thanks for the help.

  • Thanks 99Instances2Go. The link you provided is a great help.

    I think the "How events work" page in the manual needs to be updated to include some information about that.

  • Thanks 99Instances2Go. Your solution seems to work.

    I am still not sure why adding an unrelated behaviour or changing the width makes a difference in this case.

    I am interested in learning more about "root-events" and when can object properties be accessed after creation. Is there a section in the manual about that?

  • Thanks again Gmoney. I did check that Red and Green are NOT solids.

    Could you please add "Destroy outside layout" behaviour to yours and try it again? On mine that seems to break it.

  • Thank you very much for that capx Gmoney. It helped a lot.

    Your example works fine while mine (which is exactly the same) doesn't. After spending some time comparing the two files I noticed that your Pink sprite is smaller than mine. I tried making it bigger and it stopped working!!

    I tried several width/height combinations and it seems to work fine for width less than or equal to 15. Anything bigger it doesn't work. Height doesn't seem to matter.

    A sprite with width 20 should easily pass through that path.

    What I need to know now is why is this happening with width greater than 15?

    Why does making it "solid" matter for path finding?

    Why is it not the same for height?

    Any thoughts on this are highly appreciated.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi Gmoney,

    Thanks for the reply. I am not trying to find a path in solids. I am trying to make my enemy sprite "solid" then do "find path behaviour".

    Here is an image of my level/events:

    jpst.it/N25y

    The blue lines are solid.

    Red sprite spawns Pink sprite

    Pink sprite tries to find path to Green sprite.

    This works fine if Pink doesn't have "Solid" behaviour. As soon as I add "Solid" to Pink sprite, it stops working!!

    Does path finding not work from solid objects?

    Thanks again.

  • I did a very simple path finding test where the path is "L" shaped. There is one sprite at one end of the path that spawns the enemy sprites. The Enemy needs to find a path to a sprite at the other end of the path.

    It all works fine until I add the "solid" behaviour to my enemy sprite. The enemy sprite fails to find a path!!

    Is that a know issue?

    The reason I want to use the solid behaviour with my enemy is to try to prevent the enemies from overlapping on the path.

    Many thanks in advance for you help.

  • That clears it. Thanks.

  • Thanks for the reply Ashley. You said:

    [quote:2jfimzp0]so unless you call a function (or a trigger runs) everything will happen in the exact order you specify.

    I have my enemy creation done with a time trigger. First type of enemy is created every 3s, Second type every 5s and third every 7s.

    Does that mean if the time trigger happens for 2nd enemy, it could interrupt the event triggered by the first enemy? If that happens then I can see a potential problem in the way I am creating the enemies.

    If so, is there a better way to create enemies and link them to their health bar that doesn't suffer this issue?

    Thanks again.

  • Hello,

    I am still in the learning phase so this is probably trivial for the advanced developers among you.

    I tried looking for the answer but I couldn't find it. Probably I am not using the correct keywords.

    Basically, I am trying to assign a "health bar" to an enemy. The advice I read was to avoid the UIDs. I am using a global variable instead that gets incremented every time an enemy is created. It goes something like this:

    1- Create enemy.

    2- Increment global_var.

    3- Assign global_var to enemy.local_var

    4- spawn a health bar.

    5- assign enemy.local_var to health bar.local_var.

    6- Pin health bar to global var.

    Am I guaranteed that steps 2 and 3 (part of the same event) will happen without interruption? Can another enemy creation event happen in a different thread and cause the global_var to be incremented between steps 2 and 3?

    Many thanks.

Taweel's avatar

Taweel

Member since 31 Aug, 2016

None one is following Taweel yet!

Trophy Case

  • 8-Year Club
  • Email Verified

Progress

9/44
How to earn trophies