# Projectile collision problem, ideas needed

#### LostFonDrive

##### Veteran
Hi guys,

In my project the player has access to an at-will projectile that can be fired forwards, and it travels in a straight line for a few steps and then disappears. It will be used in puzzles, initiating combat etc.

However I have a problem relating to collision. If the projectile is fired at a wall, it is stopped by the wall, which makes sense. But this also happens when fired at any other collision boundary, for example if you are standing next to a river and you fire the projectile, it will be stopped by the river which does not make sense, it should fly over the river.

I am struggling to think of a solution because I don't think you can selectively make an event go 'through' collision specifically for water or whatever but not for walls. I am stumped. Any ideas?

#### Andar

##### Veteran
the problem here is that the passability system of the engine is absolute, it does not make a difference as to the reason for the impassability.

The 'easiest' solution (which will still require a lot of work) is to use the terrain tags to determine the "height" of a tile to be checked by whatever causes the movement of the projectile.
It can be done both by eventing and javascript plugin depending on what exactly you want, but it is not something easy to program either way.

#### Bex

##### Veteran
You could make the Projectile pass through everything. But if it hits a certain Region, it is handled like it hits a target or it just disappears. That Region is painted on all Walls and obstacles which should not be passed by the Projectile.

1. Mark the "Through" Box in the Projectile Event.
An Event with Projectile Graphic, through box marked, move frequency: highest and speed to max?.
2. Paint Region 1 over all Walls and obstacles that should not be passed by the Projectile.
3. In the Event for the Hit detection we also add a conditional branch that checks the Region Id on the Coordinates: X = Projectile Map x and Y = Projectile Map y.
When the Projectile Moves a step, the mapcoordinates change before the Projectile visibly moves to the next Map Tile, so if we detect that the Projectile hits Region1, than we can deactivate the Projectile Eventpage and make it disappear. You could additionaly play an Animation where a Bullet wall splash happens. But lets start with the basics.
4. You need one parallel Event that is checking if the bullet hits a target or a Wall, this Event should only be active when a Projectile is active on the Map and aslong the Projectile is moving.
5. You need another Parallel Event that is checking if the Shoot Projectile Button got pressed, if yes, than it needs to set the projectile event infront of the player and turn it away from player and move 8 steps forward.

In theory that should be all, but Andar is right, this isn't easy.

#### Andar

##### Veteran
Paint Region 1 over all Walls and obstacles
That is why I suggested terrain tags instead of region ID. Because the terrain tag is defined in the tileset it automatically applies to all tiles of that tileset without the need to pain every map with region IDs.

The region ID would only be the better solution if you have cases where identical tiles are used in different circumstances requiring different passability.

Bex

#### LostFonDrive

##### Veteran
Thanks for the responses, guys. I hadn't considered I could use terrain tags or Region ID for this.

### Latest Profile Posts

My spirit can be so easily wounded by most things that nobody thinks twice about. It may be not a big deal to you, but it means EVERYTHING to me!
I have to make a custom tree for my FSM game and I'm nervous I won't get it right.
Finally got the tablet picture!
Working hard on my Mode7 interiors in between calls at work!
A good idea rise a moment before falling asleep, and survive the second coffee the day next morning.