Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Do AGK2 physics collisions always get reported as contacts?

Author
Message
dirahl
9
Years of Service
User Offline
Joined: 2nd Jan 2015
Location:
Posted: 2nd Jan 2015 22:29
I'm creating simple spaceship game, just fly around and shoot the other guy's ship with missiles. I turned bullet physics on for the missiles, and everything seems to work fine..."nearly" all the time. Every once-in-a-while a missile will bounce off the ship (without a player death), or two missiles will bounce off each other. It doesn't seem to matter how fast they are going.

I check for collisions by examining the contact list. In these cases, it doesn't appear that the collisions are being reported to the contact list. I have debug code that reports the full contents of the list.

Is there a good place to go that really explains how the contact list works?

Attachments

Login to view attachments
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 2nd Jan 2015 23:00
I don't know the answer to your question, sorry!, but could you not make the missiles sensors (SetSpritePhysicsIsSensor(Spr, 1)? Assuming you are detecting collisions correctly, this should stop any bouncing off...
swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 2nd Jan 2015 23:42
Be sure to check both A and B of the contact list. Honestly though I believe it may be an AppGameKit bug.

dirahl
9
Years of Service
User Offline
Joined: 2nd Jan 2015
Location:
Posted: 3rd Jan 2015 15:54
I figured it out. I'm not sure if you'd call it a bug or not. I was using SetSpriteAngle, which apparently doesn't check for physics collisions (not a surprise, since it doesn't have the word "Physics" in it). Therefore, bullets would bounce off the ship any time the player was rotating it during contact. It's not an obvious behavior; clearly the check was done at some level, or the bullet wouldn't have bounced. But the check didn't make it to the contact list, so maybe you'd call that a bug.

Thanks for your responses, though. I've been messing with it for less than a week, so I'm bound to do some dumb things.
unlikely
12
Years of Service
User Offline
Joined: 5th Mar 2012
Location: Ohio, USA
Posted: 4th Jan 2015 00:12
I had something similar to this happen... I never did figure out what was causing it, but now that you've posted that, it sounds likely. I would call it a bug for sure.
rfwarrior
9
Years of Service
User Offline
Joined: 13th Jan 2015
Location:
Posted: 11th Feb 2015 20:02
Aaarrrggghhh.


I've just spent ages trying to debug something similar.

if setSpriteAngle is set on a sprite with physics enabled that object will not report collisions.

So - the question is, can anyone suggest any work arounds?

could I have an invisible sprite that I rotate and allocate the resulting image to the sprite with physics?

I'll see if I can come up with something and will post back if I get it working.
rfwarrior
9
Years of Service
User Offline
Joined: 13th Jan 2015
Location:
Posted: 11th Feb 2015 20:39
Okay I've investigated further.

From what I can tell if you use setSpriteangle then collision detection won't work on that sprite for that cycle.

In my code I was setting sprite angle even if it hadn't changed and so no collisions were detected.

so I changed my code to only use setSpriteAngle. that fixed the collision detection, unless I was holding my left or right rotate buttons.

So I changed my code further to only check the rotate buttons every other cycle - I had to change my rotation angle from 2 to 4 to keep the rotation speed the same.

Collision detection is now working flawlessly.

By cycle I mean each iteration round the do /sync loop.

Hope this helps someone.

Login to post a reply

Server time is: 2024-11-25 16:56:02
Your offset time is: 2024-11-25 16:56:02