Author Topic: smooth camera  (Read 1247 times)

cl0udi

  • Wannabe
  • Posts: 16
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Firefox 40.0 Firefox 40.0
    • View Profile
  • Playstyle: Keyboard
smooth camera
« on: August 22, 2015, 06:55:03 PM »
how to make smooth camera in tower rooms please answer thanks

klazen108

  • Administrator
  • The Kid
  • Posts: 286
  • your a kid now your a squid now
  • OS:
  • Windows NT 10.0 Windows NT 10.0
  • Browser:
  • Chrome 44.0.2403.155 Chrome 44.0.2403.155
    • View Profile
    • Delicious-Fruit
  • Playstyle: Keyboard
Re: smooth camera
« Reply #1 on: August 22, 2015, 07:11:39 PM »
hi sir pls make new object put this code in events and then put in room thx

Code: [Select]
////////////////Create Event:
smoothness_factor=6;

view_object=object_index;
view_vspeed=-1;
view_vborder=view_hview/2;
view_hborder=view_wview/2;


//////////////////////Step Event:
if (instance_exists(player)) {
    target_x=player.x;
    target_y=player.y;
   
    dist=point_distance(x,y,target_x,target_y);
    if (dist>64) {
        x=player.x;
        y=player.y;
        speed=0;
        exit;
    }
}
speed=dist/smoothness_factor;
direction=point_direction(x,y,target_x,target_y);
if (speed<1) speed=0;


////////////////////////////Room Start:
//copy of step event, to prevent flashing on room start

if (instance_exists(player)) {
    target_x=player.x;
    target_y=player.y;
   
    dist=point_distance(x,y,target_x,target_y);
    if (dist>64) {
        x=player.x;
        y=player.y;
        speed=0;
        exit;
    }
}
speed=dist/smoothness_factor;
direction=point_direction(x,y,target_x,target_y);
if (speed<1) speed=0;