Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Smooth Camera (https://forums.graalonline.com/forums/showthread.php?t=134265056)

Emera 11-19-2011 07:38 PM

Smooth Camera
 
I have seen this done before on other servers. Basically, it's when a character moves or your mouse moves to a different x and the camera kinda lags behind you and when you stop, the camera springs into position. Classic uses something like this when you activate their mouse search were you can search across levels.

A more recent example is Esteria's camera behaviour when a player moves. Can anybody help me out?

iBeatz 11-19-2011 07:55 PM

Try using:

PHP Code:

setfocus(floatfloat); 


Emera 11-19-2011 07:56 PM

Quote:

Originally Posted by iBeatz (Post 1674664)
Try using:

PHP Code:

setfocus(floatfloat); 


I know you have to use setfocus ;P
But it quickly snaps to the player. I want it to glide to the player smoothly. I have seen it done on Esteria.

iBeatz 11-19-2011 08:00 PM

Quote:

Originally Posted by Emera (Post 1674666)
I know you have to use setfocus ;P
But it quickly snaps to the player. I want it to glide to the player smoothly. I have seen it done on Esteria.

Just set the focus on a timeout, and just move the camera along the delta between the player and focus point divided by how much you want it to glide for before it reaches the player.
I haven't done it before but I assume that's how you would do it.

Tricxta 11-19-2011 10:19 PM

What you could do is store an array of the players past x and y values. Then you just call them up and plonk them into setfocus. I would write you up a piece of code but it's relatively simple and a good exercise for you to nut out.

Emera 11-19-2011 10:30 PM

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
onTimeout();
}

function 
onTimeout() {
  
temp.speed 0.1;
  
temp.cx += ((player.x) - cx) * speed;
  
temp.cy += ((player.y) - cy) * speed;
  
setfocus(cxcy);
  
setTimer(0.05);


Would this work?

DustyPorViva 11-19-2011 10:46 PM

The camera lagging behind the player is a horrible gameplay mechanic, btw.

Tricxta 11-19-2011 10:49 PM

When I saw it on classic I thought it was a bug lol

Emera 11-19-2011 10:51 PM

Am I doing this right?
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
setTimer(0.05);
}

function 
onTimeout() {
  
this.cx += ((player.x) - this.cx) * .1;
  
this.cy += ((player.y) - this.cy) * .1;
  
setFocus(this.cxthis.cy);
  
setTimer(0.05);



Tricxta 11-20-2011 12:11 AM

That's not the method I'd use Emera. So yer I can't tell wether you're on the right track or not due to me not being able to make sense of your logic

Fulg0reSama 11-20-2011 12:20 AM

Quote:

Originally Posted by Emera (Post 1674704)
Am I doing this right?
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
setTimer(0.05);
}

function 
onTimeout() {
  
this.cx += ((player.x) - this.cx) * .1;
  
this.cy += ((player.y) - this.cy) * .1;
  
setFocus(this.cxthis.cy);
  
setTimer(0.05);



Did you test it..?

Emera 11-20-2011 12:22 AM

Quote:

Originally Posted by Fulg0reSama (Post 1674709)
Did you test it..?

Yeah just did. It works a treat. Thanks Trix.
It works as I would expect it to work, but if there's a better way to do it, then I'm all ears. :D

ffcmike 11-20-2011 04:12 AM

The camera does not lag behind you on Classic anymore as it did pre-wipe, it is simply a portable focus where you press C (or whatever key of your choosing), can move the mouse around and click to freeze the focus on a spot.

Emera 11-20-2011 11:17 AM

Quote:

Originally Posted by ffcmike (Post 1674728)
The camera does not lag behind you on Classic anymore as it did pre-wipe, it is simply a portable focus where you press C (or whatever key of your choosing), can move the mouse around and click to freeze the focus on a spot.

That's what I was trying to say, but it has a smooth camera motion to it.


All times are GMT +2. The time now is 05:28 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.