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?
tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,949
Custom collision shapes are not available in GameSalad. The two possible collision shapes are rectangle and circle. It's possible to make ramps using a series of rectangles rotated to form a smooth-ish surface, but it's a pain to do so.
Custom collision shapes are not available in GameSalad. The two possible collision shapes are rectangle and circle. It's possible to make ramps using a series of rectangles rotated to form a smooth-ish surface, but it's a pain to do so.
You could plot them automatically with an expression.
tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,949
You could plot them automatically with an expression.
True. Actually, I have a game I started working on pre-tables that involves curved surfaces and I'm ready to return to it now that I can pre-determine the locations, sizes, and rotations of actors via a table.
Custom collision shapes are not available in GameSalad. The two possible collision shapes are rectangle and circle. It's possible to make ramps using a series of rectangles rotated to form a smooth-ish surface, but it's a pain to do so.
You could plot them automatically with an expression.
Please tell me how I can find out more about this technique?
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:
tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,949
@Socks the hills demo is exactly what I was needing for the game I put on hold. The only thing I don't quite get is how to specify the starting y position. In that file, the starting Y value is always 290.467 based on game.Time. What if I want the curve to start at Y=0?
. . . how to specify the starting y position. In that file, the starting Y value is always 290.467 based on game.Time . . .
I'm not 100% sure what you mean ? Not sure where you are getting 290.467 from either (I might just be misunderstanding your question) ?
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
tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,949
Yes, that's pretty much it. I have hill graphics (which I now need to remake to fit the sin function) but let's say I place a hill somewhere on the scene. I'm trying to figure out how I would make the curve begin (it's lowest point) at self.position.X-self.size.Width/2,Y=0.
Yes, that's pretty much it. I have hill graphics (which I now need to remake to fit the sin function) but let's say I place a hill somewhere on the scene. I'm trying to figure out how I would make the curve begin (it's lowest point) at self.position.X-self.size.Width/2,Y=0.
If you want the sin function (or cos for that matter) to start at 0 (or wherever) then just turn (or 'offset') the angle accordingly (here we are using game.time as the angle so it just keeps rotating automatically), do this by adding (or subtracting, or whatever you want) from the angle.
AAA*sin( game.Time *BBB-90)+CCC
tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,949
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 !