Custom Collision Shapes?
Zenith_Gameworks
Member Posts: 310
If I wanted to make a ramp with realistic collision (not exactly straight but like an exponential curve), how could I go about doing that, if it would be possible?
Comments
Need Help? Email Me | Templates | Full Game Source Code
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Darren.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
What I mean is that you can use an expression to draw a series of 'dots' (small actors) to define the edge of the curved surface:
Example 1: http://www.mediafire.com/?vrnms26lr5a0v9h
Example 2: http://www.mediafire.com/?bnho5bu7xaldiau
Here is the same thing with the collision points even more spaced out, hopefully you can see that you don't really need them to be that close for a curved collision surface - obviously in the actual game all these collision actors would be invisible - and your graphics with nice smooth corners would sit over the top:
Example 3: http://www.mediafire.com/?ebhl0dbh477waxi
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
80*sin( game.Time *300)+120
The Y value is 120.
The 80*sin part at the start of the equation raises and lowers the Y value by 80 pixels.
The game.Time *300 part defines how fast the 80*sin will raise and lower the Y value.
. . . . so Y is 120, but it sweeps up to 200 (120 + 80) and sweeps down to 40 (120 - 80).
If you wanted to have the curve start at 0 (I presume you mean the base of the curve ?) . . then you need to do this . . .
AAA*sin( game.Time *BBB)+CCC
AAA = range of sweep
BBB = speed of sweep
CCC = centre of sweep
So, the centre of the sweep needs to be the same as the range of sweep, if the centre is 120 (120 pixels 'off-the-ground'), then the range of sweep needs to be 120, so it sweeps up to 240 pixels and then down to 0 pixels (120 pixels each way).
So . . . 120*sin( game.Time *BBB)+120
Hope that makes sense ! (Hope I've understood your question).
Ah ! I've think I've just understood your question (I think) !?
Do you mean you want the curve to start at the lowest point in its cycle ?
i.e: If we have a curve like this, you want it to start on-the-ground ?
If that's the case, the you just need to offset the angle of the sine by 90°:
120*sin( game.Time *300-90)+120
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
AAA*sin( game.Time *BBB-90)+CCC
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
(ugh, the YouTube timeline gets in the way... just imagine green ground on either side of the hill.)
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Looking good ! >-