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 / Physics: Multiple Contact Points T2

Author
Message
Greg_C
13
Years of Service
User Offline
Joined: 22nd May 2010
Location:
Posted: 2nd Feb 2012 20:35
I might be going about this the wrong way but here it is: The basics of what I am trying to do is make it so I can jump only when my players "feet" are on the ground. The way I thought about doing it is through the contact points that are returned through the physics. Now this works fine in most cases:



The problem lies when there are multiple contacts happening at the same time. For instance if the character is running on the ground and then hits a wall the contact point that returns is not >= the bottom of my sprite because it is returning the contact point of the wall even though it is colliding with the floor.

I can get away with this with my current game but I am really just wondering what everyone else is doing to check if the player is touching the ground. Or if there are some other ideas that I could test out.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Feb 2012 21:10
I am using raycasting for this and other similar operations. You can set all of your "ground" sprites to a particular group then do a raycast from the sprite's centre down to just below where his feet are and check for a collision against that group.

It's a lot simpler than it sounds once you look at the commands. Contacts are far less predictable in my experience.

bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 2nd Feb 2012 21:11 Edited at: 2nd Feb 2012 21:12
I have a sprite that I position at the player sprite's feet. I use it as a sensor.

Quote: "
I am using raycasting for this and other similar operations. You can set all of your "ground" sprites to a particular group then do a raycast from the sprite's centre down to just below where his feet are and check for a collision against that group.
"


That sounds like a better solution. I'm gonna give it a try.


Greg_C
13
Years of Service
User Offline
Joined: 22nd May 2010
Location:
Posted: 3rd Feb 2012 00:35 Edited at: 3rd Feb 2012 01:21
That's why I ask these questions wasn't even thinking about doing a raycast. Thanks for response!

EDIT:

After looking at the raycasting functions I decided I don't really need to filter out what the character is hitting just need to know if he is hitting something:



Thanks for the help!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd Feb 2012 09:45
Great. Glad to help!

I'm also using raycasting to decide how dark my object's shadows should be as it also returns data you can get a distance from.

bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 5th Feb 2012 15:18 Edited at: 5th Feb 2012 23:06
Quote: "I'm also using raycasting to decide how dark my object's shadows should be as it also returns data you can get a distance from. "


Good thinking.

I'm using a variable on the character to let it know it's on the ground. I send two raycasts down, one on each side of his feet, and if either is on the ground then I assign a third variable:



Login to post a reply

Server time is: 2024-05-06 09:40:41
Your offset time is: 2024-05-06 09:40:41