Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411558 Posts in 69384 Topics- by 58443 Members - Latest Member: junkmail

May 03, 2024, 10:05:00 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Collision Detection in Construct
Pages: [1]
Print
Author Topic: Collision Detection in Construct  (Read 1491 times)
stolide
Level 0
**


Quaff, oh quaff this kind nepenthe!


View Profile
« on: April 04, 2010, 03:07:56 PM »

Hello everyone, I am back for awhile probably. I am working on a turn-based-strategy game in construct, but for some reason, a lot of collisions seem to go undetected. Could someone explain the kinds of things that cause this?

Thanks in advance.
Logged

Sites of mine,

(On energetic dualism) http://teneonon.weebly.com/

(Homebrew tabletop rpgs) http://quomodo.weebly.com/
Falmil
Level 6
*


View Profile
« Reply #1 on: April 04, 2010, 04:02:43 PM »

Tunneling? An object completely jumps over/passes through another object because there's too much time between updates and/or it moves too far each update. Though, if you're making a turn based game, I'm not sure where you're having collision issues or needing collisions.
Logged
stolide
Level 0
**


Quaff, oh quaff this kind nepenthe!


View Profile
« Reply #2 on: April 04, 2010, 04:40:04 PM »

Tunneling? An object completely jumps over/passes through another object because there's too much time between updates and/or it moves too far each update. Though, if you're making a turn based game, I'm not sure where you're having collision issues or needing collisions.

When one unit shoots at another, I have an object the travels in the direction the firing unit is facing. Whatever the projectile collides with is hit. This allows for misses without any random elements, as well as friendly fire amongst other things.

If there is a better way, I am open to it. I currently have the player input x and y coordinates that units travel towards. The face whatever direction they travel, and if you choose to spend your turn having a unit shoot, it shoots in the direction it was last moving. It forces you to be careful how you end your unit, and use your other units to bait enemies into firing lanes.

It is odd though, I just messed around with it a bit. The player's units can hit enemies. However, the enemies cannot hit the player's units. I am reusing the same projectile, and the same code for each. I figure there is probably some kind of setting on one of the units that is causing it not to be hit by the projectile.
Logged

Sites of mine,

(On energetic dualism) http://teneonon.weebly.com/

(Homebrew tabletop rpgs) http://quomodo.weebly.com/
Rob Lach
Level 10
*****



View Profile WWW
« Reply #3 on: April 04, 2010, 05:17:58 PM »

Are the enemies always missing? If not what percentage.
Logged

stolide
Level 0
**


Quaff, oh quaff this kind nepenthe!


View Profile
« Reply #4 on: April 04, 2010, 05:55:35 PM »

Are the enemies always missing? If not what percentage.

The only time an enemy hit, out of the times it should have, the target was a few pixels away from it. So probably 99% of the time, something is going awry.
Logged

Sites of mine,

(On energetic dualism) http://teneonon.weebly.com/

(Homebrew tabletop rpgs) http://quomodo.weebly.com/
Rob Lach
Level 10
*****



View Profile WWW
« Reply #5 on: April 05, 2010, 01:43:37 AM »

My best guess without looking at exactly what you did and just going by your description there are 2 possible issues.

1. The projectile is colliding with enemy before it gets a chance to travel towards the player (which could be fixed by checking if the collision is with the source and ignoring that. When a player is close it might catch the collision at the spawn of the projectile with the player.

2. That you're setting an offset or vector incorrectly. Which would be odd considering you'd have to separate those calculations somehow.
Logged

stolide
Level 0
**


Quaff, oh quaff this kind nepenthe!


View Profile
« Reply #6 on: April 05, 2010, 03:10:46 AM »

I think I am spawning the object inside the enemy. I will try spawning just in front of it. The odd part is I am spawning inside of the player's units, and it works for them...
Logged

Sites of mine,

(On energetic dualism) http://teneonon.weebly.com/

(Homebrew tabletop rpgs) http://quomodo.weebly.com/
raigan
Level 5
*****


View Profile
« Reply #7 on: April 05, 2010, 05:53:14 AM »

"I am reusing the same projectile, and the same code for each"
"I am spawning inside of the player's units"

This makes me suspect that you have some sort of filter on the projectile so that it ignores player units, which works when it's used by the player but fails when used by the enemies. Just a random guess though.
Logged
moi
Level 10
*****


DILF SANTA


View Profile WWW
« Reply #8 on: April 05, 2010, 04:37:23 PM »

I seem to remember that in construct you had to be careful what condition you tested.
Sometimes you had to use "overlaps" instead of "collides" and vice versa. Or something like that.
Also : construct forums.
Logged

subsystems   subsystems   subsystems
Akari
Level 2
**



View Profile
« Reply #9 on: April 06, 2010, 12:16:30 AM »

"I am reusing the same projectile, and the same code for each"
"I am spawning inside of the player's units"

This makes me suspect that you have some sort of filter on the projectile so that it ignores player units, which works when it's used by the player but fails when used by the enemies. Just a random guess though.
I'd suspect this being the most likely cause for your problem. How are you setting things up so that the player characters don't hit themselves when shooting? Private variable? Have you tried running your game with the debugger and tracking the private variable of the spawned bullet when an enemy shoots?
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic