Jump to content
A 2021 backup has been restored. Forums are closed and work in progress. Join our Discord server for more updates! ×
SoaH City Message Board

Flames trail behind Sonic in Damizean's engine!


Recommended Posts

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.:confused:

please and thank you,

- Zonar Games

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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

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.:confused:

Link to comment
Share on other sites

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

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. :P

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...