Zonar Games Posted July 8, 2006 Report Share Posted July 8, 2006 I have been coding a script for Gamemaker 6 where if Sonic runs a certain speed(top_x_speed) flames trail behind sonic on the ground to emulate a sence of speed. I already coded the flame object where the instance only lasts for a millisec then destroys the instance. But I'm having trouble in Sonic's object trying to make flames trail behind Sonic while running at top speed. Here is what I think could work: if ( top_x_speed = 4 && ground == true ){ instance_create(blah,blah,objFlames) } Something like that but what I done just does'nt work at all. Can anyone help me with my script please? I want when Sonic is running at a certain speed/ top speed, flames create from behind Sonic on the ground.(Not the flames in mid air but trailing on the ground.) I will give major credit. please and thank you, - Zonar Games Link to comment Share on other sites More sharing options...
Kain Posted July 8, 2006 Report Share Posted July 8, 2006 If you're going to use ==, then make sure your engine accurately stops at that speed (cause anything higher wouldn't make it). It's better to use >=. Anyway, the main problem here is that you're checking the top_x_speed compared to some constant and top_x_speed sounds like a constant, so comparing the two will always be the same. You should be comparing the current x_speed to the top_x_speed or some constant, above which, you'd be flaming. Also, don't forget that Sonic can be moving fast backwards, in which case it'd be a large negative value, so you have to use the absolute value function "abs(...)" which gets rid of the sign. if( abs(x_speed) >= 5 && ground == true) { instance_create(blah,blah,objFlames); } Anyway, to get the flames to be on the ground, it's just trigonometry. Basically, look at the values in the collision_bottom script and copy the coordinate scripts replacing "argument0/1" for "x/y" and "argument2" for angle: (x + sin(degtorad(angle)) * 11, y + cos(degtorad(angle)) * 11) Edit: Also, note that the center of the flame sprite should be at the bottom center of the sprite. 1 Link to comment Share on other sites More sharing options...
Zonar Games Posted July 8, 2006 Author Report Share Posted July 8, 2006 Thanks kain! It worked all I got to do is play around with it to make it perfect. - Zonar Games Link to comment Share on other sites More sharing options...
Kain Posted July 8, 2006 Report Share Posted July 8, 2006 No problem. You might consider reading up on the lengthdir_x and lengthdir_y functions, as they are more understandable if you're not that knowledgable in trig or just don't want to deal with sin/cos/tan. Basically, you put in the angle you want it to go and how far away you want it to go and it gives you what you need to add to your x to get the desired point (for lengthdir_x and y for lengthdir_y). Link to comment Share on other sites More sharing options...
Zonar Games Posted July 9, 2006 Author Report Share Posted July 9, 2006 I kinda had trouble with using length_x/y. I wanted to makr the flames appear behind Sonic an it generated an error. instance_create(x + length_x(5,angle)) * 11,y + length_y(0,angle)) * 11,obj_flames); [/CODE]Kain can you tell me whats wrong with this code? It is not creating a short distance behind Sonic. Link to comment Share on other sites More sharing options...
Kain Posted July 9, 2006 Report Share Posted July 9, 2006 Actually, they're "lengthdir_x" and "lengthdir_y". Anyway, the way lengthdir_x/y functions work is you give them the same distance and angle and add them seperately (one to x and one to y). Also, going in direction "angle" would be going in front of them; if you want behind, it's either "-angle" of "angle" with a negative length: instance_create(x + lengthdir_x(-5,angle),y + lengthdir_y(-5,angle),obj_flames); (oh, you were also using to many end parenthesis; try and count them to make sure they match) Link to comment Share on other sites More sharing options...
Damizean Posted July 9, 2006 Report Share Posted July 9, 2006 Hmmm, interesting function Kain, never saw it maybe I should change the whole cos/sin for this Link to comment Share on other sites More sharing options...
Kain Posted July 9, 2006 Report Share Posted July 9, 2006 I juggle between the two methods, myself; sometimes I use lengthdir_x/y and other times sin/cos (never both at once). I'm more used to using sin and cos and a -y is pretty hardcoded in my head. But the lengthdir_* method certainly an easier point of view to look at if the problems more a matter of direction than math. lengthdir_y(5,angle-90) is easier to understand than -sin(degtorad(angle-90))*5 or some sin/cos switch as a method to go 5 to the right of the angle you're on/facing. Also, there's no need to use arctan2 when you have point_direction. Link to comment Share on other sites More sharing options...
Zonar Games Posted July 9, 2006 Author Report Share Posted July 9, 2006 oh I made a huge mistake. I used the wrong command. Edit: Your avatar is cool Damizean!!! Just had to say that.xD Link to comment Share on other sites More sharing options...
revolutiongames2004 Posted July 10, 2006 Report Share Posted July 10, 2006 i like the idea, if you want it to look really cool, animate it to look like it come up from the ground and goes back down. it would look good if it were about 6 frames long Link to comment Share on other sites More sharing options...
Zonar Games Posted July 10, 2006 Author Report Share Posted July 10, 2006 thank, I'm trying to make the effect the best I can to make it look unique in other words. Link to comment Share on other sites More sharing options...
Recommended Posts