Need help to make a projectile system

Not favoritedFavorited Favorited 0 favourites
  • 6 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Subscribe to Construct videos now

    Hey so im in deep need of help, i want to make a game (duh) in which you attack ennemies by throwing projectiles at them, those projectiles latch onto them and deal continuous damage, said projectile also will follow the player behind ( you could compare this to pikmins).

    My problem is i cant manage to make the projectile latch onto the ennemy, and whenever the projectile is thrown, it can be thrown infinitly again no matter if its following the player or not, I also wanted to know how i could manage to make multiple entities follow the player without them stacking on top of eachothers.

    Here is the code i made so far:

    Thank you in advance for those willing to anwser and help me!

  • The second-to-last event in your screenshot makes the projectile follow the player every tick - that’s why it doesn’t stay on the enemy.

    Also, why are you using so many movement behaviors? Follow, MoveTo, and Bullet all conflict with each other.

    Instead of the Follow behavior, you can just attach the sprite using the hierarchy. The logic would look like this:

    On start of layout: 
     Add Projectile as a child to the Player (sync X and Y)
    
    On click
    Player Pick child Projectile: 
     Projectile set bullet enabled and launch in mouse direction
    
    Projectile on collision with Enemy: 
     Projectile set position to Enemy
     Enemy add Projectile as a child
    
    
    Every 1 second
    Enemy Pick child Projectile: 
     Enemy subtract from Health
    
  • You're epic, thanks alot dude, i think you probably guessed im still kinda inexperimented to all this lol, but thanks again! <3

  • The second-to-last event in your screenshot makes the projectile follow the player every tick - that’s why it doesn’t stay on the enemy.

    Also, why are you using so many movement behaviors? Follow, MoveTo, and Bullet all conflict with each other.

    Instead of the Follow behavior, you can just attach the sprite using the hierarchy. The logic would look like this:

    > On start of layout: 
    Add Projectile as a child to the Player (sync X and Y)
    
    On click
    Player Pick child Projectile: 
    Projectile set bullet enabled and launch in mouse direction
    
    Projectile on collision with Enemy: 
    Projectile set position to Enemy
    Enemy add Projectile as a child
    
    
    Every 1 second
    Enemy Pick child Projectile: 
    Enemy subtract from Health
    

    So i tried your child thing for the enemy damage, but didnt seemed to work, so i proceeded to do something else, and now it works, but the problem is every instance of that ennemy gets destroyed when the health reach zero, im sure i need to use the UID system but didnt seemed to work..

  • In the second event, you need to pick the enemy instance which each Pikmin is pinned to.

    For each Pikmin
    System Pick Enemy By Evaluate Enemy.UID=Pikmin.Pin.PinnedUID
    

    That's why I suggested using the hierarchy - it's a lot easier because you can use "pick children" and "pick parent" conditions.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you again!!!

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