Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AbrahamR, wdlmaster, 7th_zorro, dr_panther, 1 invisible), 764 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Camera turn around player #221480
08/14/08 08:48
08/14/08 08:48
Joined: May 2007
Posts: 185
Netherlands
SurudoiRyu Offline OP
Member
SurudoiRyu  Offline 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.

Code:
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 smile

Greetzzz, and thnx allready


-The Dragon's Eye is alway's watching you!-
Re: Camera turn around player [Re: SurudoiRyu] #221486
08/14/08 09:51
08/14/08 09:51
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
I posted this snipper a while ago. It revolves the camera around an entity whilst looking at it.

You might need to tweak it a bit, but the basic structure is there...

http://www.coniserver.net/ubb7/ubbthread...9528#Post219528

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 Offline OP
Member
SurudoiRyu  Offline OP
Member

Joined: May 2007
Posts: 185
Netherlands
Ok thnx smile

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.

Code:
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 smile

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 Offline OP
Member
SurudoiRyu  Offline 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 Offline
User
Trooper119  Offline
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 Offline
User
Trooper119  Offline
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]:
Code:
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 Offline OP
Member
SurudoiRyu  Offline 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:
Code:
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 Offline
User
Trooper119  Offline
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 Offline OP
Member
SurudoiRyu  Offline 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 Offline
User
Trooper119  Offline
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
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1