wilmer
Member
Greetings to all:
Trying to summarize, Through code I make the View follow the player and when he throws a grenade and explodes a shaking effect is created, the problem is that with my code the View has to wait for the shaking effect to end to continue to the character, causing a sudden movement of the View. How can I avoid seeing that Cut seen in the Video?
This is All the code
obj_Control // Object that makes the view follow the player
obj_Granade // When this object touches the ground it explodes and the shaking effect is activated
obj_Shaking
Trying to summarize, Through code I make the View follow the player and when he throws a grenade and explodes a shaking effect is created, the problem is that with my code the View has to wait for the shaking effect to end to continue to the character, causing a sudden movement of the View. How can I avoid seeing that Cut seen in the Video?
This is All the code
obj_Control // Object that makes the view follow the player
min_view_x=0
min_view_y=0
max_view_x=room_width-camera_get_view_width(view_camera[0]);
max_view_y=room_height-camera_get_view_height(view_camera[0])
min_view_y=0
max_view_x=room_width-camera_get_view_width(view_camera[0]);
max_view_y=room_height-camera_get_view_height(view_camera[0])
if obj_Shaking.CanShake == false
{
halfViewWidth = camera_get_view_width(view_camera[0])/2;
halfViewHeight = camera_get_view_height(view_camera[0])/2;
cx=obj_parentpp.x-halfViewWidth
cy=obj_parentpp.y-halfViewHeight
cx=clamp(cx,min_view_x,max_view_x)
cy=clamp(cy,min_view_y,max_view_y)
camera_set_view_pos(view_camera[0],cx,cy )
}
{
halfViewWidth = camera_get_view_width(view_camera[0])/2;
halfViewHeight = camera_get_view_height(view_camera[0])/2;
cx=obj_parentpp.x-halfViewWidth
cy=obj_parentpp.y-halfViewHeight
cx=clamp(cx,min_view_x,max_view_x)
cy=clamp(cy,min_view_y,max_view_y)
camera_set_view_pos(view_camera[0],cx,cy )
}
obj_Granade // When this object touches the ground it explodes and the shaking effect is activated
if place_meeting(x,y,objBlock) //This is the object of the Floor
{
if instance_number(obj_Granade) == 0
{
instance_create(x,y-20,obj_GranadeExplosion) //is the object or sprite of the explosion
}
obj_Shaking.alarm[0]=0.4*room_speed
if obj_Shaking.alarm[0] > 0
{
obj_Shaking.CanShake = true
}
instance_destroy();
}
{
if instance_number(obj_Granade) == 0
{
instance_create(x,y-20,obj_GranadeExplosion) //is the object or sprite of the explosion
}
obj_Shaking.alarm[0]=0.4*room_speed
if obj_Shaking.alarm[0] > 0
{
obj_Shaking.CanShake = true
}
instance_destroy();
}
obj_Shaking
shake_x=camera_get_view_x(view_camera[0])
shake_y=camera_get_view_y(view_camera[0])
CanShake = false
shake_y=camera_get_view_y(view_camera[0])
CanShake = false
//Check when you can shake
if (CanShake)
{
camera_set_view_pos(view_camera[0],shake_x + irandom(6) ,shake_y + irandom(6) )
}
///Shake
if (CanShake) exit;
shake_x = camera_get_view_x(view_camera[0]);
shake_y = camera_get_view_y(view_camera[0]);
if (CanShake)
{
camera_set_view_pos(view_camera[0],shake_x + irandom(6) ,shake_y + irandom(6) )
}
///Shake
if (CanShake) exit;
shake_x = camera_get_view_x(view_camera[0]);
shake_y = camera_get_view_y(view_camera[0]);
camera_set_view_pos(view_camera[0],shake_x,shake_y)
CanShake = false;
CanShake = false;
Last edited: