• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM (SOLVED) lengthdir_y is not doing anything

S

Shadowblitz16

Guest
can someone confirm if this is a bug in gms 1.4?
basicly I have separated my sine motion and my linear motion into two sections
I can confirm that my velocity is 5 and my angular is 0 when I come to line 43 and 44 however it doesn't seem to be doing anything.

Code:
/// Update Projectile

//////////////////////////////////////////////////////////////////////////////////////////////////////
// Tail
//////////////////////////////////////////////////////////////////////////////////////////////////////

if ((instance_exists(spawner)) && (spawner.object_index != Projectile))
if (tails > 0)
{
    scr_projectile_spawn(json, config[? "id"], 90, xstart, ystart)
    tails --;
}


//////////////////////////////////////////////////////////////////////////////////////////////////////
// Apply Movement
//////////////////////////////////////////////////////////////////////////////////////////////////////
if (update)
{


    //////////////////////////////////////////////////////////////////////////////////////////////////////
    // Wave Motion
    //////////////////////////////////////////////////////////////////////////////////////////////////////
  
    amplitude_value = clamp((amplitude_value + amplitude_accel) - amplitude_decel, amplitude_base, amplitude_peak);
    oscillation_value = clamp((oscillation_value + oscillation_accel) - oscillation_decel, oscillation_base, oscillation_peak);
  
    oscillation += degtorad(oscillation_value);
    var _shift = amplitude * sin(oscillation);
  
    oscillation_x += lengthdir_x(speed, angular);
    oscillation_y += lengthdir_y(speed, angular);
  
    x = oscillation_x + lengthdir_x(_shift, angular + 0);
    y = oscillation_y + lengthdir_y(_shift, angular + 0);
  
  
    //////////////////////////////////////////////////////////////////////////////////////////////////////
    // Linear Motion
    //////////////////////////////////////////////////////////////////////////////////////////////////////
  
    x += lengthdir_x(velocity, angular + 90); //< seems to be offsetting it slightly
    y += lengthdir_y(velocity, angular + 90); //< does nothing
    var test = 0;
}
 

obscene

Member
You are using lengthdir_y correctly, there's definitely no bug with it. I can't follow your code to help you with the problem but the function is fine.
 

TheouAegis

Member
If by the time the last two lines are run angular is 0, then lengthdir_x is velocity and lengthdir_y is 0. Then at angular+90 they are swapped, so lengthdir_x is 0 and lengthdir_y is velocity, negative when needed.
 
S

Shadowblitz16

Guest
@obscene here is my latest project if it helps you follow my code
@TheouAegis sorry I don't understand.
where is it swapping? i'm offsetting it by 90 for the movement since I want direction 0 in my game to be up

Edit: Nevermind I found out that I didn't need to increment x any since the wave already did it for me
I just removed the last two lines
 
Last edited by a moderator:
Top