1 registered members (Ayumi),
662
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
mouse_pos3D
#430595
09/29/13 14:29
09/29/13 14:29
|
Joined: Dec 2009
Posts: 361
rtsgamer706
OP
Senior Member
|
OP
Senior Member
Joined: Dec 2009
Posts: 361
|
Hi, I am making a top down game with twin stick type controls. I am using the following lines to make the player character look at the mouse cursor:
while (my)
{
vec_to_angle (my.pan,mouse_pos3d);
my.tilt = 0;
}
It works fine except for the fact that once I move from x=0, y=0 it doesn't work any more. I think it's because the command I'm using checks the cursor's position in relation to the origin. But I don't understand it in depth enough to know hwo to fix it. Is there a way that I can either chose the reference point as something I can move dynamically. Or is there another command or something that'll fit my needs better? Thanks
|
|
|
Re: mouse_pos3D
[Re: rtsgamer706]
#430609
09/29/13 18:35
09/29/13 18:35
|
Joined: Dec 2009
Posts: 361
rtsgamer706
OP
Senior Member
|
OP
Senior Member
Joined: Dec 2009
Posts: 361
|
Here's the entire loop, maybe my problem is with how I'm moving the camera or something
while (my)
{
vec_to_angle (my.pan,mouse_pos3d);
my.tilt = 0;
//-----------Movement-----------
camera.x = my.x;
camera.y = my.y;
if (key_w)
c_move (me, nullvector, vector(20*time_step, 0, 0), IGNORE_PASSABLE); // move the player forward
if (key_s)
c_move (me, nullvector, vector(-20*time_step, 0, 0), IGNORE_PASSABLE); // move the player forward
wait(1);
}
|
|
|
Re: mouse_pos3D
[Re: Superku]
#430709
10/01/13 00:58
10/01/13 00:58
|
Joined: Dec 2009
Posts: 361
rtsgamer706
OP
Senior Member
|
OP
Senior Member
Joined: Dec 2009
Posts: 361
|
Camera.tilt = -90 and I have this in main:
while (1) { mouse_pos.x = mouse_cursor.x; // allow the mouse pointer to move mouse_pos.y = mouse_cursor.y; // on the x and y axis wait (1); }
plus
mouse mode = 2;
am I forgetting something?
Last edited by rtsgamer706; 10/01/13 00:58.
|
|
|
Re: mouse_pos3D
[Re: rtsgamer706]
#430713
10/01/13 01:11
10/01/13 01:11
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
Then debug the code (on your own), check critical values before calculation and the like. Btw. this is how mouse_dir3d behaves:
void main()
{
fps_max = 60;
level_load(NULL);
camera.z = 512;
camera.tilt = -90;
mouse_mode = 4;
while(1)
{
DEBUG_VAR(mouse_dir3d.x,20);
DEBUG_VAR(mouse_dir3d.y,40);
DEBUG_VAR(mouse_dir3d.z,60);
wait(1);
}
}
You can try to add a "if(mouse_dir3d.z < 0) {...}" line around your mouse target calculation block.
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|