1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 Camera Modes

Discussion in 'Programming' started by MuddyMuddy, Nov 9, 2019 at 12:28 PM.

  1. MuddyMuddy

    MuddyMuddy Member

    Joined:
    Mar 2, 2017
    Posts:
    176
    Regarding the 'Follow Object' and 'Peak Out' modes from FreindlyCosmonaught's video.



    Does anyone know how I can combine these two modes? So the the camera follows the player, unless the mouse is at the edges of the screen, where it would peak out a bit, then Lerp back to the player when not at the edge?

    So far I am using the regular Peak Out mode, but want to extend when it peaks out.

    cx = lerp(o_char.x,mouse_x,0.4) - (view_w/2);
    cy = lerp(o_char.y,mouse_y,0.4) - (view_h/2);


    EDIT: So I have managed to do it like so:
    Code:
    if !point_in_rectangle(mouse_x,mouse_y,cx+(view_w*0.05),cy+(view_h*0.05),cx+(view_w*0.95),cy+(view_h*0.95)){near = 0;}else{near = 1;}
    
    if near = 0{
    if temp != 0.4{temp+=0.02;}  
       
    cx = lerp(o_char.x,mouse_x,temp) - (view_w/2);
    cy = lerp(o_char.y,mouse_y,temp) - (view_h/2);
    }
    
    if near = 1{
    temp = 0;
    cx = o_char.x - (view_w/2);
    cy = o_char.y - (view_h/2);
    }}
    
    camera_set_view_pos(view_camera[0],cx,cy);

    Does anyone know how I can Lerp back to the player after 'near = 1'? i.e. this part (atm it snaps back):

    if near = 1{
    temp = 0;
    cx = o_char.x - (view_w/2);
    cy = o_char.y - (view_h/2);
    }
     
    Last edited: Nov 9, 2019 at 1:22 PM

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice