How do I make turrets aim for a different image point?

0 favourites
  • 11 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • I am making a tower defense game, and I want the turrets to aim for another image point on the enemies that is not their origin... How to do this?

  • by aim for another image point you mean the turret bullet to hit another part of the target? or the way the turret is following the target?

  • I mean, it would be very strange for the bullet to hit the center of the enemy while the cannon is clearly aiming for the top left sooooo...

    I mean both (;

  • I mean, it would be very strange for the bullet to hit the center of the enemy while the cannon is clearly aiming for the top left sooooo...

    I mean both (;

    ehm move the origin point of the target? or make the image container frame larger, and have the image be smaller inside? not sure why hitting the center is a issue, all games are doing the same thing. but i guess ... imagepoint reposition will fix it.

  • Oh, sorry, I think I didn't make it clear that I need the origin to be in the top left, but the turrets to aim for the center.

  • I don't think you can make the turret behavior target a specific image point.

    You could however create a second invisible sprite, add it to a container and hierarchy with your other target sprite, and appropriately offset it so that the origin is where you want to be targeting. Then you just need to switch your target to the new sprite and make sure that the original still has the interaction with your projectile.

    Example: 1drv.ms/u/s!AkmrWgxeuxlKhIdX8ioRcCTXjjuwSg

    Otherwise you can create your own custom turret behaviour using events and use the imagepointX(), imagepointY() expressions to aim towards a specific imagepoint.

  • I already used ImagePointX/Y(<number>) before and it seamed to just use the origin instead... Any idea why?

  • No idea without seeing your code, but the example i posted above shows you how to achieve what you want by using an extra sprite.

  • Ok, thank you for everything (;

    Edit: Just saw your example, why did you set the bullet angle to turret angle? Don't you know construct does this automatically?

  • learning every day

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Turret -> Spawn "TurretBullet" (image point 1)

    TurretBullet -> Set angle (TurretBullet.Angle-anglediff(angle(Turret.ImagePointX(1), Turret.ImagePointY(1), Enemy.x, Enemy.y), angle(Turret.ImagePointX(0), Turret.ImagePointY(0), Enemy.x, Enemy.y)))

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