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 - Player moving with platform (Tier 1)

Author
Message
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 1st Mar 2012 14:49
Hello, I'm currently creating a little platform game... I have created a series of static and moving platforms which the player can jump on. The issue I have is that if the player jumps on the platform which is moving from left to right, the player stays still and the platform moves from underneath him. I need the player to move with the platform... I have tried applying a ridiculous amount of friction, which did kinda work (it was just abit jerky), I was wondering if anyone had any other ideas...

I can throw an example together and post the code if that will help?

Many thanks,

Dan
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Mar 2012 17:35
How are you controlling the player's movement? If you are setting velocity then that might be the cause. For moving platforms you either:
1-set the player speed using impulse or force
2-add the velocity of your moving platform to your player when he is standing on it

Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 2nd Mar 2012 16:08
Thanks Baxslash, yes, I am currently using Velocity... I have tried to use Impulse and Force, but I cannot stop the sliding effect (as if he's on an ice rink)... What do I need to do to stop the character immediately after releasing the direction? Here is the code I have (no media needed),



Thanks, as always...
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Mar 2012 16:21
Here's a simplified solution using your code:


Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 2nd Mar 2012 17:01
Genius... Just so I understand (else I won't learn), is this basically looking for a collision (via RayCast) between the platform and player, and if so, applying the same amount of velocity to both the platform and player?

I think I need to look into RayCasting abit more... Not sure I quite grasp that concept...

Thanks Baxslash, really appreciate it...
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Mar 2012 17:09
Ray casting is just like shining a laser from one point to another. It can then tell you:
a-If it hit anything on the way
b-How far away the thing was
c-Its spriteID
etc.

You can also specify a sprite group or even a single sprite to look for along that line.

Login to post a reply

Server time is: 2024-11-23 04:50:09
Your offset time is: 2024-11-23 04:50:09