Enemy with hitbox glitching when there is more of him

0 favourites
  • 7 posts
From the Asset Store
Tweakable and easy to use effects for your projects.
  • Hello I was trying to make a enemy that's composed by a hitbox and a sprite for the animations, but when there isn't only one of him in the layout they struggle to work ok. I wanted to each one work idependently.

    here is the cp3 file: drive.google.com/file/d/1gt84imsdlNiDPzeYSZ8Jt9Uw0_hRQ7N-/view

    NOTE: to test the enemy, go to the W 1-5 layout and his code is on the "Enemies" event sheet on the "Treemons" group

  • Can you make a small demo or post a screenshot of the event sheet? Your project is 27MB in size and requires addons which I don't want to install.

  • Here you are:

  • Remove "trigger once" from all events and never ever use it inside of triggers, loops, and especially with objects that have multiple instances! It's the cause of all your bugs.

    Instead of "trigger once" use additional conditions, or Timer behavior. For example, in the last event on your first screenshot you can add another condition: Tween "Idle" is not playing.

    Timer is a very useful behavior for such games. For example:

    Enemy has LineOfSight to Player 
    Enemy timer "attack" is not running : Enemy start timer "attack" for 1 second
    
    Enemy On timer "attack" : Enemy spawn a bullet
    

    This is a proper alternative to "trigger once" and "wait 1 second" (which won't work correctly for multiple instances).

  • It's like this?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah, it looks better. Although this event is still wrong:

    It will run on every tick while the conditions are true, and will create lots of delayed threads - because of "Wait 0.5s" action. So even if another event starts the "Attack" timer and set Attacking to true, those delayed threads will reset Attacking variable back to false for half a second.

    Avoid using Wait action in non-triggered conditions.

  • It's working slightly better, but you didn't understood. They were glitching when there were multiple instances, and I wanted to them work independently from each other.

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