Help..Camera panning RPG

Posted By: MMike

Help..Camera panning RPG - 08/13/09 15:29

Hello, i've been looking around but nothing came up.

i want to pan the camera like google maps..

You hold the left key, and then move the mouse, and the camera will move the same amount.

I tryed mouse_force, but if it wont work, like i want:
- the mouse speed is not considered and the panning is always +1 because that mouse_force... so if i drag faster it wont move faster.

So my question is. How do i code such thing, so that when i drag from point A to point B, the point will end right over the mouse, and not outside the mouse position.

i tryed mickey.x but that move too fast...

PS:my camera should also mantain a tilt of -58 to the floor.


Thanks..
Posted By: MMike

Re: Help..Camera panning RPG - 08/14/09 19:25

guys come one, anyone?


function camera_pan(){
camera.tilt=-59; //looking to the ground slightly
while(1){
if(mouse_left){
camera.x+=mickey.y / 69;
camera.y+=mickey.x/87; //this valoues i dont know why are these but there //should be a reason
}

wait(1);}
}


when i move , and grab a point in the ground the point will
move with the mouse, but will past the mouse position, when it must keep the mouse position exaclty.

Posted By: Max_Prower

Re: Help..Camera panning RPG - 08/14/09 23:32

Working on it; I'll edit this post when I figure it out. Is what you're looking for a way to change the panning speed depending on how fast you're moving the mouse?

If so, this might help:

Create a variable to handle 'acceleration'. "camera_accel", is an example of a good name. This variable will remain at 0 when you aren't dragging, but will be given a value depending on mouse_force's value.

So if mouse_force == 0 then camera_accel would be 0 as well,

if (mouse_force >= 2 && mouse_force < 4) {camera_accel = 4;}
if (mouse_force <= 2 && mouse_force < -4) {camera_accel = -4;}

Do you get the idea? We're changing the acceleration value based upon the value of mouse_force (how fast we are moving the mouse).

For a basic panning camera:

Some people try something like:

camera.x = mouse_force.x * 5;

That doesn't work, and when you take a look at it the reason is fairly obvious; the camera's x value is going back to zero again because that's the value of mouse_force when the mouse isn't being moved.

The trick is to ADD the mouse_force to the camera.x, not SET camera.x to be equal to mouse_force. You could to it the same way with the keyboard:

if (key_cul == 1) {camera.x -= 5}

That's an example of what I mean.
--------------------------------------
Or: It might simply be because your statements are in a while loop. If you find your movement being really oversensitive, try taking it out of a while loop.


I hope this helped you, bye! ^^

P.S: to PAN the camera in 3DGS often means to turn it as if it's spinning on a pole (with it's z axis), not to pan it across an area like you would in Black and White.
Posted By: MMike

Re: Help..Camera panning RPG - 08/18/09 17:11

but? your saying mouse_force>=2 ? thats impossible? because mouse_force is just from
-1 to 0 to 1 ?
I dont get it.

That limitation, of mouse force being just 1 to -1 thats the origin of my problems.. because it doesn't account with the speed of it.

And i want to move the camera like Sims for example, but you need to hold left and drag to the camera to mov.. i already got a way of handling this through mouse mickey.. but its not accurate, because, when i press the mouse, at an object, and drag the camera, the object is no longer over the mouse point that was clicked before drag.. (so it lakes speed adjustments).

But the mouse force thing im in doubt? i though it were range 1
© 2024 lite-C Forums