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 Studio Chat / Move sprite with up/down "hill"

Author
Message
DannyD
6
Years of Service
User Offline
Joined: 29th Aug 2017
Location:
Posted: 28th May 2019 09:58
HI Guys
Is there someone who can point me in the right direction, to move a sprite "up" and "down" according to another sprite.
Like walking uphill/downhill.
See attached example. AppGameKit Studio
Thanks, Appreciate
Danie

Attachments

Login to view attachments
IronManhood
9
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
Posted: 28th May 2019 18:33
Well I think the simplest thing to do is just enable 2d physics and give the ground sprite a custom shape.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 29th May 2019 08:48
Agree with IronManhood to some extent. Using physics can make character control easier if you can get your head around controlling physics objects "properly" as you don't have to calculate movement due to gravity or interactions between objects as long as they are created as physics objects.
If you still want full control and your game is not too complicated you can just use physics for the ground and use raycasting to detect where the ground is. Then you can position your character based on this. You can even get the "normal" angle, which is the reflected angle of the raycast to work out if the ground is sloped and edit your character speed based on this. It opens up a lot of functionality which CAN make things simpler than calculating them all yourself.
Using AppGameKit V2 Tier 1
DannyD
6
Years of Service
User Offline
Joined: 29th Aug 2017
Location:
Posted: 30th May 2019 03:18
Thanks Baxslash & Ironmanhood. I've never used 2d Physics before. Will do some research and look for some examples
Thanks, appreciate

Login to post a reply

Server time is: 2024-03-29 14:54:06
Your offset time is: 2024-03-29 14:54:06