Hi Everyone! Let me ask are the shooting units in RTS or in some games, it seems like they don't have to fire AREA2D bullets to kill enemies. But they only deal damage to the exact enemy they're shooting at. But they don't shoot like the area2D bullet form. So how do they shoot and calculate damage? Maybe when an enemy enters the "Overlapping Area", the enemy's -HP? Without having to wait for the bullet to fly out to collide with the enemy? Please answer me. Thank you so much!

Not sure if I understand your question but you can use a physical projectile and apply damage on an overlap or collision or you can use a raycast and apply damage to the hit object.

Yup, I'm using a physical projectile. But what I mean is in some RTS games I feel like they don't use projectiles. Because once unit A aims and shoots unit C, when unit B crosses it, the unit won't get damaged. From that, there is no bullet line between A and C. But I think it's just unit C's -HP when unit C enters unit A's damage area. I think so, not sure if it's true. What do you think?

To implement a bullet, I would use an Area that is attached to the weapon of choice. Then if the bullet can only pass to one enemy, check the distance to see which enemy is closer to the weapon mounting point for the Area. So get the overlapping enemies and do distance to see who is closer.

Bullets travel fast, really fast. But if you need a delay on it, you can use delta.

I already know how to use the problem you're talking about. But what I'm asking is is there any other way than that? For example the way I am describing above. If the enemy is in the player's field of view then we subtract HP without bullets.Do you think the way I just suggested is ok, Mr Newmodels?

I believe if the bullet is traveling fast enough, and the area is the size of the bullet, it will skip. Because it will be in one location then another making one big leap. A problem I came across when making a space ship warp system. The ship was traveling fast enough to skip asteroids. Passing through them without collision. A problem with the limitation of computer software. One solution was to make the Area bigger so to not miss any collision.

If you're looking for an alternative to relying on projectile collision, I think something like this would work:

  • When a unit attacks, it targets a specific enemy (which might be explicitly selected by the player, or might be triggered when an enemy enters an area denoting the unit's range)
  • A new attack scene (which may or may not look like a projectile and does not need to have an Area2D) is instanced with a reference to the target and whatever damage information is relevant (i.e. damage amount and maybe type)
  • When the attack scene gets to the appropriate point in its animation/movement, it deals damage to the target (probably after calling is_instance_valid on the reference to prevent crashes if the enemy was destroyed since the attack started)
  • The attack scene finishes its animation and calls queue_free on itself

So basically the attack starts off knowing what it's going to hit rather than starting off in a direction and waiting to run into something. I think that would result in the behavior you're describing.

Yup, you answered exactly what I was asking. My idea was to use an overlapped area2D, no bullets needed. Any enemy that enters it has its -HP. Of course the nearest enemy priority must also be calculated. Do you think that's possible, Mr. Soundgnome?

Yeah I think it's totally possible, just a question of how you want the targeting to work. I'm not clear on whether you're thinking of an area-of-effect attack which would simultaneously damage all enemies within range, or a single-target attack that could only hit one enemy at a time, even if multiple are in range. You'd have slightly different logic for those but I think either way using an area2D to detect which enemies are in range would work.

9 months later