2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Camera turn around player
#221480
08/14/08 08:48
08/14/08 08:48
|
Joined: May 2007
Posts: 185 Netherlands
SurudoiRyu
OP
Member
|
OP
Member
Joined: May 2007
Posts: 185
Netherlands
|
Hi there, Im willing to rotate my mouse around my player entity. It is a 3rd person cam and mouse rotate 360 degrees around the player. This can be done by right mouse button. I got this so far now i can change it allready with the mouse but i can not get it so that i rotate around the player so i can face the entity's front.
function Camera_Action()
{
var mouseR_onhold = 0;
camera.tilt = -15;
while(1)
{
vec_set(camera.x,vector(-180,0,50));
vec_rotate(camera.x,my.pan);
vec_add(camera.x,my.x);
camera.pan = my.pan;
if(mouse_right) // right Mousebutton pressed?
{
mouseR_onhold = 1;
mouse_map = NULL;
camera.pan -= mouse_force.x;
my.pan -= mouse_force.x;
camera.tilt += mouse_force.y;
}
if(!mouse_right && mouseR_onhold == 1)
{
mouse_map = arrow;
}
wait(1);
}
}
Hope someone can help me change my code so that it becomes what i want Greetzzz, and thnx allready
-The Dragon's Eye is alway's watching you!-
|
|
|
Re: Camera turn around player
[Re: DJBMASTER]
#221570
08/14/08 21:17
08/14/08 21:17
|
Joined: May 2007
Posts: 185 Netherlands
SurudoiRyu
OP
Member
|
OP
Member
Joined: May 2007
Posts: 185
Netherlands
|
Ok thnx I tryed to play a bit with the code But it became some real mess >.< it goes around the player start pos now. but doesn't walk with the char. It goes one side very quick. It doesnt work as it should be. Maybe because i just use camera. and not an entity. Tries diffrent things but all just sucked. Even de start pos. got screwed a bit.
function Camera_Action()
{
var mouseR_onhold = 0;
var centerx = 0; // centre of circle (x)
var centery = 0; // centre of circle (y)
var radius = 400; // radius of circle
var theta = 0; // degrees done around the circle
var temp;
camera.tilt = -15;
while(1)
{
//vec_set(camera.x,vector(-180,0,50));
vec_rotate(camera.x,my.pan);
//vec_add(camera.x,my.x);
camera.pan = my.pan;
if(mouse_right) // right Mousebutton pressed?
{
mouseR_onhold = 1;
mouse_map = NULL;
camera.pan -= mouse_force.x +(radius * sin(theta));
my.pan -= mouse_force.x;
camera.tilt += mouse_force.y;
theta+=1*time_step;
//camera.x = centerx +(radius * sin(theta));
//camera.y = centery + (radius * cos(theta));
// vec_set(temp,my.x);
// vec_sub(temp,my.x);
// vec_to_angle(my.pan,temp); // now MY looks at YOU
// vec_set(camera.x,my.x - 15);
}
if(!mouse_right && mouseR_onhold == 1)
{
mouse_map = arrow;
}
wait(1);
}
}
plz can u help me fix it Thnx allready,
-The Dragon's Eye is alway's watching you!-
|
|
|
Re: Camera turn around player
[Re: SurudoiRyu]
#222212
08/18/08 13:03
08/18/08 13:03
|
Joined: May 2007
Posts: 185 Netherlands
SurudoiRyu
OP
Member
|
OP
Member
Joined: May 2007
Posts: 185
Netherlands
|
Anyone else can help me with it ?
Greetzzz,
-The Dragon's Eye is alway's watching you!-
|
|
|
Re: Camera turn around player
[Re: SurudoiRyu]
#222245
08/18/08 16:23
08/18/08 16:23
|
Joined: Apr 2004
Posts: 516 USA
Trooper119
User
|
User
Joined: Apr 2004
Posts: 516
USA
|
Well first I would define your mouse correctly what I would do (there are several ways to do it) is this define the mouse key map at the top
#define mouseRight 281
and replace if(mouse_right) with if(key_pressed(mouseRight)) //This assumes your using lite-C
Increase your sensitivity of the mouse by like 5 or 10 or so (just add * 5 ect. after mouse_force.x ect.) so you can actually see it move.
It looks like you took his code, then massacred it, instead of just taking out the automatic movement and replacing it with mouse_force movement. I'll edit with what I'm talking about below.
Last edited by Trooper119; 08/18/08 16:47.
A clever person solves a problem. A wise person avoids it. --Einstein
Currently Codeing: Free Lite-C
|
|
|
Re: Camera turn around player
[Re: SurudoiRyu]
#222254
08/18/08 16:44
08/18/08 16:44
|
Joined: Apr 2004
Posts: 516 USA
Trooper119
User
|
User
Joined: Apr 2004
Posts: 516
USA
|
Assuming this code works as described, all you need to do is assign the angle according to mouse_force (and a modifier). Pretty much ignore my previous post, I got confused and started babbling, that was my fault. Your Code [editted]: function Camera_Action()
{
var mouseR_onhold = 0; //Not needed
var centerx = 0; // centre of circle (x)
var centery = 0; // centre of circle (y)
var centerz = 0; //Change these to point to your player
var radius = 400; // radius of circle
var thetaX = 0; // degrees done around the circle
var thetaZ = 0;
my = player = camera; //Important, he is using a my pointer, since for
//whatever reason your not making the camera
//an action, you need to get the my pointer point to the camera somehow
camera.genius = camera; //This you could probably get rid of, depends on what you want
while(1)
{
camera.pan = my.pan;
camera.tilt = clamp(camera.tilt,-70,70); //Change tilt to what you want or get rid of this
if(mouse_right) // right Mousebutton pressed?
{
mouseR_onhold = 1; //Not needed
mouse_map = NULL; //It would be nice if you checked if mouse_map wasn't NULL before-hand
thetaX+=mouse_force.x * 5; //I'd make a variable for 5 and tweak it to what
//you want the sensitivity to be, same with next one
thetaZ+=mouse_force.y * 5;
camera.x = centerx + (radius * sinv(thetaX));
camera.y = centery + (radius * cosv(thetaX));
camera.z = centerz + (radius * cosv(thetaZ)); //might be sinv() or tanv(), tweak till you like the result
vec_set(temp,centrex);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp); // now MY looks at YOU
vec_set(camera.x,my.x);
}
//Your previous function was round-about, I'd do this
if(mouse_map == NULL)
{
mouse_map = arrow;
}
wait(1);
}
}
Last edited by Trooper119; 08/18/08 18:58.
A clever person solves a problem. A wise person avoids it. --Einstein
Currently Codeing: Free Lite-C
|
|
|
Re: Camera turn around player
[Re: Trooper119]
#222261
08/18/08 17:24
08/18/08 17:24
|
Joined: May 2007
Posts: 185 Netherlands
SurudoiRyu
OP
Member
|
OP
Member
Joined: May 2007
Posts: 185
Netherlands
|
Hi thnx for your reply, I had sort of the same in first place did the same as it does now. It places the camera in the center coords of the player and looks up. and i cant rotate it. aswell the camera isnt attached to the player anymore. code that i use atm: function Camera_Action()
{
var mouseR_onhold = 0;
var centerx = 0; // centre of circle (x)
var centery = 0; // centre of circle (y)
var radius = 400; // radius of circle
var theta = 0; // degrees done around the circle
var temp;
//
camera.tilt = -15;
while(1)
{
vec_set(camera.x,vector(-180,0,50));
vec_rotate(camera.x,my.pan);
vec_add(camera.x,my.x);
camera.pan = my.pan;
if(mouse_right) // right Mousebutton pressed?
{
mouse_map = NULL;
camera.pan -= mouse_force.x;
my.pan -= mouse_force.x;
camera.tilt += mouse_force.y;
}
if(!mouse_right && mouseR_onhold == 1)
{
mouse_map = arrow;
}
wait(1);
}
} i like to use this but then rotate like the most online RPG games. Now it rotates with the player aswell, but i want to rotate around the player so i can see its face or watch my back. hope u can help me, Greetzzzz,
Last edited by SurudoiRyu; 08/18/08 17:25.
-The Dragon's Eye is alway's watching you!-
|
|
|
Re: Camera turn around player
[Re: SurudoiRyu]
#222270
08/18/08 18:10
08/18/08 18:10
|
Joined: Apr 2004
Posts: 516 USA
Trooper119
User
|
User
Joined: Apr 2004
Posts: 516
USA
|
In order to keep the player and camera together, adjust the center variables so they point to the player's x and y variables.
What does my code do, bug up, or does it run? Let me know so I can help. Also what does your code currently do?
Last edited by Trooper119; 08/18/08 18:10.
A clever person solves a problem. A wise person avoids it. --Einstein
Currently Codeing: Free Lite-C
|
|
|
Re: Camera turn around player
[Re: Trooper119]
#222277
08/18/08 18:38
08/18/08 18:38
|
Joined: May 2007
Posts: 185 Netherlands
SurudoiRyu
OP
Member
|
OP
Member
Joined: May 2007
Posts: 185
Netherlands
|
Well my code does:
Place the camera behind the player. Keep the same panning. Rotate the camera when i rightclick the mouse button and rotates the direction u go with your mouse.
the code u passed does: place the camera on the plyers x y z so im inside the player. doesn't keep same panning. Doesnt rotate the camera according the mouse force And looks up to the sky.
So my code is almost there the only thing is the tilting and panning.
Panning u can compare to the camera of World of warcraft im trying to get something like that.
greetzzz. hope u understand if not i will make an example.
-The Dragon's Eye is alway's watching you!-
|
|
|
Re: Camera turn around player
[Re: SurudoiRyu]
#222279
08/18/08 18:42
08/18/08 18:42
|
Joined: Apr 2004
Posts: 516 USA
Trooper119
User
|
User
Joined: Apr 2004
Posts: 516
USA
|
I understand your post, did you try DGBMASTER's code as an action (you can't control it, but did you test to see if it works?)
EDIT: I changed the code, it shouldn't help much since not much has changed, I'm thinking if you take a hard look at all of the contributions so far you should be able to think of something
Last edited by Trooper119; 08/18/08 19:36.
A clever person solves a problem. A wise person avoids it. --Einstein
Currently Codeing: Free Lite-C
|
|
|
|