How do I keep projectiles from hurting the character that fired them? If the bullet is in collision with the player, the player gets hurt. If the bullets are at the center of the player, they are in collision with the player. But my player can shoot, and the bullets are spawned at the player’s center.
I know, I could just have the player shoot a different bullet, but that’s more work. Because I have an angled top-down view, some of my bullets are just below the ground, the simplest form of bullet, and others are invisible but have an image of a regular bullet hovering over them, which is both graphically and mechanically different, and it would be a whole lot of work to animate this twice. Furthermore, the game is party-based, and I like the idea of friendly fire. I just like the idea of the shooters blowing themselves up every time they shoot. Not every weak attack should be one of iron-man’s heart-nukes.
Since, according to the lore, the bullets are all explosive, however, there’s an easy fix: They don’t detonate until they get far enough away. I could use “wait x seconds.” But that’s inconvenient, because most of my weapons are supposed to fire at high-speed, slow enough to be dodged, usually, but fast enough to give the player or enemy an extremely short amount of time to dodge. This means that the math, the tenths of a second, will be difficult to calculate.
So I plan on using the actually distance from their origin. But I don’t know how to do this. Does anybody else know?
Add a unique id to each player and assign that id to each bullet they fire. When checking for collision, add the condition that the bullet id != player id.
That might work but it sounds like a highly complex thing, especially when taking into account that this wouldn’t be each player, it would be each character, be it a pc or an npc.
I did come up with a simpler, but still not really good way, in which I animate the player ring object so that the bullet fires from a different point on it, however, depending on which direction the mouse is in relation to the player, or which direction the target is in relation to the NPC, but animating that and setting up the events for linking the animations to the cursor-position would take some time and effort.
Yeah. I think I’ll go with the latter. I’m actually going to make time flow from player action, anyhoo, and the bullets are moving fast enough that it shouldn’t inconvenience the player too much. I think I’ll need another sprite for the player, but it’ll be invisible, so there will be nothing to render, and that’s the simplest way to do it I can think of.