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 / Question on Collision with physics Tier 2

Author
Message
Mmarzex
11
Years of Service
User Offline
Joined: 26th Feb 2013
Location:
Posted: 4th Apr 2013 00:08
So I am trying to have it that should my player sprite collide with the enemy the player is destroyed if from the side or the enemy is destroyed if the player jumps on it. Is there a way for me to use agk::AddSpriteShapeBox() to add two different collision zones on the enemy and check for collision between the player and those boxes?
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 4th Apr 2013 00:27
Not really. There is only one collision shape for a sprite. It can be a square, circle or polygon. You can use up to 12 points to define the polygon yourself, if you want, but it must be concave only (no indents allowed).

This applies to either Tier, all the physics commands and stuff are the same in both Tiers.

You can, in theory, get the point the two sprites collide at. Then you check to see if it is on either side of the player (for hit from the side) or above the enemy (for player jumps on enemy).

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 4th Apr 2013 00:34
there are exist some Contact functions with x y positions GetSpriteContactWorldX( )
or maybe adding a sprite as sensor SetSpritePhysicsIsSensor( iSpriteIndex, sensor )
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 4th Apr 2013 00:58
Mmarzex, I use Physics Ray Cast for this... Cast a Ray down through your characters feet just a few pixels longer. And then when doing the Collision check, if the Ray Cast = 1 (as in the ray is in contact with the enemy) then the enemy will be destroyed. If the Ray Cast = 0 (as in the ray is NOT in contact with the enemy) then the character should die...

This is how I have done it with Happy Chick and it seems to work well. Its quite fiddly to get the ray cast right, but once you have it correct, its pretty flawless...

I hope that makes sense...

Login to post a reply

Server time is: 2024-11-24 11:34:23
Your offset time is: 2024-11-24 11:34:23