Whats the simplest way to detect slopes and when the player jumps, it propells them in that way slightly depending on the angle? Thanks :)
Printable View
Whats the simplest way to detect slopes and when the player jumps, it propells them in that way slightly depending on the angle? Thanks :)
Like in Sonic The Hedgehog?
I've actually never attempted to do something like that combined with a simple platform movement (Unless you want a Sonic engine..). I'll give it a go.
You could use hidden detectors (Active objects set as invisible)
If the player jumps (presses Shift) + player is overlapping hidden object (named LEFT) set a player flag (such as Flag A) to ON.
If player flag A is ON
+ every .2 second (can be any amount you like)
set player X position to player X position -1
Upon collision between player and platform object (slope), set player flag off.
The same would used for the RIGHT hidden detectors except you would use a different flag and would add 1 to the X position.
Looki, I have experience and looked in-depth into an engine you may have heard of called "Sonic Worlds" which is the most closest and exact replica of Sonic The Hedgehog, I just never understood how the angle stuff worked when looking at it.
DT, thats the exact thing I do at the moment lol! It just don't work so well when you have a curving slope or something, as you would need to create multiple sensors.
If it helps. I have 2 hidden actives on each side of the player that always position onto the floor below the player, and if there is a slope, they stay on their separate heights, which was the 1st step to how "Sonic Worlds" done it. The rest involves retrieving the angle from making the 2 hidden sensors "Look at" eachother constantly, then using the angle value to figure out the COS and SIN to figure out the value to set the X and Y speed. Jesus thats a lot of work :O
If you are trying to get that high of a percision then YES it will be a lot of work.
I'm aware of Sonic Worlds and I just made a quick example which uses the same method.
I admit that it's not very well executed/explained, but maybe it helps!
http://clickteam.info/looki/Examples/Slope.mfa
Nono! Thats perfect!! Thank you Looki, greatly appreciated :)
And thanks DT for helping out too :)
There are 'easy ways'
The only 'correct' way imo is to use an algorithm to find the normal angle of the slope of collision mask at any given point. And I developed a very nice algorithm for this for my latest project!
Basically it involves finding the points where a circle of a given radius intersects the collision mask, then taking the angle between those two points +90 as the normal angle. It has a very good mean time performance because it can start at the previous normals.
I was going to write an article on it when I got the time >_>
The 'correct' way is to have vector collision data instead of bitmask...
but then you can't do spritework :)
I have a game that can input custom levels where you simply draw the sprites, chop them into a tileset, and work with them. No vector or predefined surfaces needed! Thats the power of my happy algorithm
I'll post it tonight
Hum, i'm curious for my part, this is seem good! :)
http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=207486#Post2074 86
thar you go