(SOLVED)I literally have no idea whats causing this?? Could anyone help?

D

Den

Guest
My player object just will not move on the Y-axis even if my vspd variable is increasing or decreasing, I have tried some debugging to figure out whats causing it, I have looked through all the code the player object is using and still cant see what's stopping it from moving along the Y-axis.
I hope someone could help coz I just cant see the issue here (Hopefully it's something obvious)

Here's the players step:
Code:
///Initiate The Players Step

//Current form check logic
if(!instance_exists(obj_player_soul)){
    player_input();
    cam_on_us = true;
    view_visible[0] = true;
} else if(instance_exists(obj_player_soul)) {
    state = soul_form_state;
}

script_execute(state);

//Switch to soul form
if(OB_key) && (state != soul_form_state){
   soul_form = instance_create(x,y-45,obj_player_soul);
}

//Open && shut doors
if(position_meeting(mouse_x,mouse_y,obj_door) && (interact)) {
  switch(obj_door.image_index)
  {
    case 0: if(image_index = 0) image_index = 1;
             break
            
    case 1: if(image_index = 1) image_index = 0;
             break;         
  }
}
The players movement script:
Code:
///move_state_normal

//Apply gravity
if(!place_meeting(x,y+1,obj_solid)) {
    vspd += grav;
}else {
vspd = 0;
}

//Left & Right code
if(right_key || left_key) {
    hspd += (right_key-left_key);
    hspd_dir = right_key - left_key;
 
//Limit the speed
    if(hspd > spd) hspd = spd;
    if(hspd < -spd) hspd = -spd;
}else {
    hspd = 0;
}

//Flip the sprite
if(hspd != 0) {
    image_xscale = sign(hspd);
}

collisions();
It isn't collisions causing it coz I have turned it off and checked.
That's all the code running through the player when just moving around, Is there something i'm not seeing or what lol?
 
My player object just will not move on the Y-axis even if my vspd variable is increasing or decreasing, I have tried some debugging to figure out whats causing it, I have looked through all the code the player object is using and still cant see what's stopping it from moving along the Y-axis.
I hope someone could help coz I just cant see the issue here (Hopefully it's something obvious)

Here's the players step:
Code:
///Initiate The Players Step

//Current form check logic
if(!instance_exists(obj_player_soul)){
    player_input();
    cam_on_us = true;
    view_visible[0] = true;
} else if(instance_exists(obj_player_soul)) {
    state = soul_form_state;
}

script_execute(state);

//Switch to soul form
if(OB_key) && (state != soul_form_state){
   soul_form = instance_create(x,y-45,obj_player_soul);
}

//Open && shut doors
if(position_meeting(mouse_x,mouse_y,obj_door) && (interact)) {
  switch(obj_door.image_index)
  {
    case 0: if(image_index = 0) image_index = 1;
             break
           
    case 1: if(image_index = 1) image_index = 0;
             break;        
  }
}
The players movement script:
Code:
///move_state_normal

//Apply gravity
if(!place_meeting(x,y+1,obj_solid)) {
    vspd += grav;
}else {
vspd = 0;
}

//Left & Right code
if(right_key || left_key) {
    hspd += (right_key-left_key);
    hspd_dir = right_key - left_key;
 
//Limit the speed
    if(hspd > spd) hspd = spd;
    if(hspd < -spd) hspd = -spd;
}else {
    hspd = 0;
}

//Flip the sprite
if(hspd != 0) {
    image_xscale = sign(hspd);
}

collisions();
It isn't collisions causing it coz I have turned it off and checked.
That's all the code running through the player when just moving around, Is there something i'm not seeing or what lol?

What variables are within your Create Event?
Did you take a look at the 'grav' variable?
 
D

Den

Guest
What variables are within your Create Event?
Did you take a look at the 'grav' variable?
Yeah I did grav = 1.5 and we just apply that to our vspd (which is 0)

Create event:
Code:
///Initialize The Playes Vars
hspd = 0;
vspd = 0;
spd = 2;
acell = 1;
grav = 1.5;
in_soul_form = false;
cam_on_us = false;

state = move_state_normal;

//Initiate the camera
instance_create(x,y, cam_view); //<<SKIP CODE WHILE TWEAKING THE PLAYERS MOVEMENT//
 
Yeah I did grav = 1.5 and we just apply that to our vspd (which is 0)

Create event:
Code:
///Initialize The Playes Vars
hspd = 0;
vspd = 0;
spd = 2;
acell = 1;
grav = 1.5;
in_soul_form = false;
cam_on_us = false;

state = move_state_normal;

//Initiate the camera
instance_create(x,y, cam_view); //<<SKIP CODE WHILE TWEAKING THE PLAYERS MOVEMENT//
Thanks for posting that.
So I'm not seeing how your player even moves on the Y-axis. I see that they can move Left and Right. Are you trying to make them move up and down via keys or just fall from gravity?
Also within the this code at the top:

//Current form check logic if(!instance_exists(obj_player_soul)){ player_input(); cam_on_us = true; view_visible[0] = true; } else if(instance_exists(obj_player_soul)) { state = soul_form_state; }
So it looks to me like when you create the player, they are changing into the "soul_form_state",
But then in the create event, you are setting their state to "move_state_normal"
So they probably cannot move because you are saying:

IF obj_player exists, change the state of the player into soul_form_state.

Try removing the code that checks for the player to exist. Just put the obj_player within the map, and call all of the start up code within the Create Event.
 
D

Den

Guest
So I'm not seeing how your player even moves on the Y-axis. I see that they can move Left and Right. Are you trying to make them move up and down via keys or just fall from gravity?
Yeah i'm just trying to add gravity, and oh ok my bad I'll give it a go and let you know :)
 
D

Den

Guest
Try removing the code that checks for the player to exist. Just put the obj_player within the map, and call all of the start up code within the Create Event.
Nah nothing changed man. The obj_player_soul is a completely different object to the standard player object, so it's not checking if the player exists it's checking if that obj exits.
 
Nah nothing changed man. The obj_player_soul is a completely different object to the standard player object, so it's not checking if the player exists it's checking if that obj exits.
Oh I see, sorry about the confusion!

I can give you an example from the code I'm using:
I am also using states.

obj_Player
Create Event:
Code:
/// Initialize the player object
image_speed = .2;
spd = 5;
hspd = 0;
vspd = 0;
grav = 1.0;
state = scr_Move_State;
Step Event
Code:
/// Control the state of the player

//Get input for player
scr_Get_Input();

//Use State
script_execute(state);
scr_Move_State:
Code:
//Gravity (In Air Controls)
if (!place_meeting(x, y+1, obj_Solid))
{
    vspd += grav;
}
else 
{
//Stops Gravity from causing vspd to continue downward
    vspd = 0;
(Just the gravity part)
 
I can't see anywhere that you actually change the x or y coordinates of the player. Setting vspd and hspd will do nothing as they are just variables. You need to apply those to the x and y.
eg:
Code:
x += hspd;
y += vspd;
If you are in fact setting the x/y somewhere, can you show that bit of code.
 
  • Like
Reactions: Den
D

Den

Guest
I can't see anywhere that you actually change the x or y coordinates of the player. Setting vspd and hspd will do nothing as they are just variables. You need to apply those to the x and y.
Sorry I couldn't nail it. I was confused myself, it doesn't seem like anything is REALLY wrong with it.
I found the issue guys, it was something really obvious haha I had The Y+= vspd commented out in collisions XD
 
Last edited by a moderator:
Top