GML Stay in same screen position

G

Geniusbat

Guest
The effect is very simple: I need to make the object constantly snap to the screen.
The problem is that I really need that object (not only witht the draw event), and I can make it work with something like:
"x=view_xview[0]+0;
y=view_yview[0]+0;"
The problem is that the object "moves" while the screen moves.
Any idea?
Thank you so much!
 

Binsk

Member
Um... What?

You want the object to snap to the view but not move? I suppose you can just use draw_sprite instead of having GameMaker draw the player and make sure it draws inside the view.

However the game physics for the object will take place in its actual position. Is that what you wanted?
 
G

Geniusbat

Guest
Um... What?

You want the object to snap to the view but not move? I suppose you can just use draw_sprite instead of having GameMaker draw the player and make sure it draws inside the view.

However the game physics for the object will take place in its actual position. Is that what you wanted?
I´m trying to use something else apart of "drawing" mostly because here will be objects that need to collide with that moving object.
Sorry if I didn´t explained myself.
 

Binsk

Member
Okay, then what is wrong with setting the object relative to the view like in your first post? That makes the object move like you want and the collision will be at its draw position.

What kind of game are you programming? Maybe that will help me understand what you are actually trying to do.
 
G

Geniusbat

Guest
Okay, then what is wrong with setting the object relative to the view like in your first post? That makes the object move like you want and the collision will be at its draw position.

What kind of game are you programming? Maybe that will help me understand what you are actually trying to do.
The problem is the "movement" it produces, idk how to exactly to describe, try the code and you will see that the position of the object in the screen slightly changes when the player moves.
Is an rpg.
 
G

Geniusbat

Guest
Okay, then what is wrong with setting the object relative to the view like in your first post? That makes the object move like you want and the collision will be at its draw position.

What kind of game are you programming? Maybe that will help me understand what you are actually trying to do.
Thank you so much for everything!!
 

Binsk

Member
Ah, I think I understand now. Where / how do you update your camera's position and where do you update the player's position to be inside the camera? I am suspecting that your player's position is set to update before the camera moves so that it lags slightly with the update, thus making it move around a little.
 
G

Geniusbat

Guest
Ah, I think I understand now. Where / how do you update your camera's position and where do you update the player's position to be inside the camera? I am suspecting that your player's position is set to update before the camera moves so that it lags slightly with the update, thus making it move around a little.
Right now I´m using the function that GMS already gives you to set the view to follow an object (in this case the player).
 
P

Paradox

Guest
What I've gathered you want the object to follow the view, a common trick used is

Code:
END STEP:
x = view_xview[0] + xstart
y = view_yview[0] + ystart
this will make the object follow the view.
 
G

Geniusbat

Guest
What I've gathered you want the object to follow the view, a common trick used is

Code:
END STEP:
x = view_xview[0] + xstart
y = view_yview[0] + ystart
this will make the object follow the view.
NP! I still don´t know what to do, that laggy effect still appears. I think that instead of using that object, I´m going to start from the beginning and try to use it in other ways. Thanks
 
Top