Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
1 registered members (AndrewAMD), 599 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Use c_trace to trace from player to mouse pointing position #235990
11/11/08 10:11
11/11/08 10:11
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline OP
Serious User
PadMalcom  Offline OP
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Hi I want to check if there is an entity in the position my mouse is pointing to (meant to be a moorhuhn clone).

How can I realise that using c_trace?

Example (but this one doesn't work):
Quote:
c_trace(player.x,mouse_dir3d.x,IGNORE_ME);


Any ideas?

Re: Use c_trace to trace from player to mouse pointing position [Re: PadMalcom] #235995
11/11/08 11:42
11/11/08 11:42
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
For checking if the mouse is over an entity, you can use mouse_ent.

If you want to use c_trace to check if there is something between the mouse and the entity, you can use vec_for_screen to find out the mouse position in 3d. Note that this won't check if the mouse is pointing to your entity!

Re: Use c_trace to trace from player to mouse pointing position [Re: Lukas] #236010
11/11/08 13:43
11/11/08 13:43
Joined: Oct 2008
Posts: 218
Nashua NH
heinekenbottle Offline
Member
heinekenbottle  Offline
Member

Joined: Oct 2008
Posts: 218
Nashua NH
Code:

function traceToMouse()
{
   VECTOR* mouse3D;
   mouse3D.x = mouse_pos.x
   mouse3D.y = mouse_pos.y;
   vec_for_screen(mouse3D,camera);
   mouse3D.z = player.z;
   c_trace(player.x,mouse3D.x,IGNORE_ME | IGNORE_PASSABLE);
}



Untested but thats the idea

edit: had my vectors in c_trace mixed up

Last edited by heinekenbottle; 11/11/08 13:48.

I was once Anonymous_Alcoholic.

Code Breakpoint;
Re: Use c_trace to trace from player to mouse pointing position [Re: heinekenbottle] #236082
11/11/08 19:10
11/11/08 19:10
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline OP
Serious User
PadMalcom  Offline OP
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Thanks a lot, I'll try it.

Re: Use c_trace to trace from player to mouse pointing position [Re: PadMalcom] #236090
11/11/08 19:34
11/11/08 19:34
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
You should set mouse3D.z to some high value (like 10000) before converting the vector from screen coordinates to world coordinates using vec_for_screen().
Because the .z value represents the "depth" of the position relativ to the camera.
This means: the higher the .z value the farer is the position away from the camera (in the direction the camera is looking)

As you are using lite-c you could also make use of returning a value as you are checking if there is an entity at the mouse position.
Code:
int traceToMouse()
{
   VECTOR* mouse3D;
   mouse3D.x = mouse_pos.x
   mouse3D.y = mouse_pos.y;
   vec_for_screen(mouse3D,camera);
   mouse3D.z = player.z;
   c_trace(player.x,mouse3D.x,IGNORE_ME | IGNORE_PASSABLE);

   if(you != NULL)
   {
     return(1);
   }
   else
   {
     return(0);
   }
}

// example of using the above function:
function check_MousePos()
{
  int a = 0;
  while(1)
  {
    a = traceToMouse();
    if(a)
    {  beep(); }
    
    wait(-0.5);
  }
}
// it checks every 30 seconds if there is an entity at the mouse position


Last edited by Xarthor; 11/11/08 19:41.

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