GuiCrossHair recognize the subject/item automatically

There are no stupid questions, just stupid answers.
  • 1
  • 2
15 posts Page 2 of 2
Posts: 98
Joined: Wed Dec 09, 2015 2:30 am
by Bishop » Sat Mar 23, 2019 12:53 pm
Thanks marauder2k9....where to write that script .... to playGui.cs?.....I wrote it there but get unable to find object '821 493' attempting to call function 'getEyeVector' and same for 'getEyePoint' that means this function can't find these objects? %eyeVec and %startPos....right? I must write in that script function where to look for them?
Posts: 98
Joined: Wed Dec 09, 2015 2:30 am
by Bishop » Sat Mar 23, 2019 5:29 pm
getEyeVector() and getEyePoint are in the ShapeBase Class I need get
Player shape and his eye to write this in the script?....I'm begginer to the Torque script.

EDIT: I get it.....$objID = my_player.getID();
echo("Object ID: " , $objID); I get my player capsule collision object and
there I have eye node as a child so %obj = $objID is this right? %obj.getEyePoint()...should find the eye node?
%obj = $objID.....this does not work....I got right ID from echo but Unknown command getEyeVector and getEyePoint.
Posts: 164
Joined: Wed Nov 15, 2017 8:19 am
by fLUnKnhaXYU » Sat Mar 23, 2019 9:49 pm
Bishop , I like what youre doing and appreciate you sharing the progress with it . In the editor select your player and get the ID number then , in the console type- IDnumber.geteyepoint() . If you get the answer you need the theres no problem with your player object . If you get an error then theres probably something wrong with the model / armature . The problem you mentioned could be in accessing the object ID with the function your using for the raycast . Id suggest making sure you are getting that ID number by just using an echo just before the get eyepoint or whatever method and check the result , you can also echo the eyevector etc... .

BTW I think youd set that $objectID at player onAdd . Then it change as you add respawned players .
Posts: 84
Joined: Fri Feb 27, 2015 5:13 pm
by irei1as » Sun Mar 24, 2019 1:19 pm
If you're in a single player environment (server=client) you can use the shortcuts
LocalClientConnection.player and to get the id for the control player and camera.

Like: (;

But it's only for single player use. Do not use them if you eventually plan on going multiplayer.
Posts: 98
Joined: Wed Dec 09, 2015 2:30 am
by Bishop » Sun Mar 24, 2019 10:50 pm
Thanks very much for help guys....I appreciate that.
Yes definitely singleplayer....this project it'll be a exploration walking....first person only...with some about is here [url][url] I get it working by mouse cursor...and the trick I used is that RMB is set to display the mouse the screen responds only to the mouse cursor and camera does not move... the player must now hold the RMB pressed....when player release RMB then mouse cursor is hidden and cursor
is off....and when cursor is hidden I set his position to the middle of the screen ( where is crosshair ) so when player pressed LMB....hidden mouse cursor raycasting items/objects in the scene so this looks like crosshair do raycasting :) ....and at that moment the 3d model viewer appears with clicked
item/object to explore in detail.....then when player clicks again with LMB but only outside of the model/item in the scene, 3dmodel viewer disappears and when RMB is pressed inside or outside
of the model/item and 3d model viewer is just on the screen and player don't want to explore anything in the 3d it disappears.
This works really well and the advantage is that the cursor is available on RMB click for use on other things.

.....but i'll try the crosshair raycasting solution but with thisI I'm quite satisfied.
..... I will post later a gif where it will be better to see in action.
  • 1
  • 2
15 posts Page 2 of 2

Who is online

Users browsing this forum: Bing [Bot] and 2 guests