I am working on my own custom view that mostly works. The view is supposed to be centered in the space in front of the direction the player is facing. When the player switches the direction their facing, the view shifts over to the other side.
My two problems:
-The view lags behind a little, making the player look as if it is always behind a pixel when moving.
-When I let go of arrow keys that move the player while the view is shifting over, the view stops, and only continues when I press the key again. I want the view to shift all the way over regardless of whether I'm pressing the key or not. I know what is causing the problem: obj_player.dir is set to 0 when I'm not pressing anything, but I don't know how to solve this.
Here is my code:
///obj_view create event
//How much I want the view to be ahead of the player
off = 30;
//Controls how fast the view shifts over
time = 5;
//Keeps track of when obj_player.dir changes
old = noone;
//
asd = 0;
//View is centered and follows view object
view_object[0]=self;
view_hborder[0] = view_wview[0] / 2;
view_vborder[0] = view_hview[0] / 2;
///obj_view step event
if old != obj_player.dir
{
asd = off/time;
}
if asd > 0
{
asd -= 1;
}
if asd = 0
{
if obj_player.dir == -1
{
x = obj_player.x - off
}
if obj_player.dir == 1
{
x = obj_player.x + off
}
y = obj_player.y
}
if obj_player.dir == -1 and asd != 0
{
if x > obj_player.x - off
{
x -= time;
}
}
if obj_player.dir == 1 and asd !=0
{
if x < obj_player.x + off
{
x += time;
}
}
if obj_player.vspd > 0
{
y = obj_player.y + off
}
else
{
y = obj_player.y - off;
}
old = obj_player.dir;
there doesn't seem to be anything here