### GuiCrossHair recognize the subject/item automatically

There are no stupid questions, just stupid answers.
• 1
• 2

#### Re: GuiCrossHair recognize the subject/item automatically

Bishop
Posts: 71
Joined: Wed Dec 09, 2015 2:30 am
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'
....so that means this function can't find these objects? %eyeVec and %startPos....right?.....so I must write in that script function where to look for them?

#### Re: GuiCrossHair recognize the subject/item automatically

Bishop
Posts: 71
Joined: Wed Dec 09, 2015 2:30 am
getEyeVector() and getEyePoint are in the ShapeBase Class .....so I need get
Player shape and his eye node....how 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);........so I get my player capsule collision object and
there I have eye node as a child so %obj = $objID is this right?....so.... %obj.getEyePoint()...should find the eye node? EDIT1: %obj =$objID.....this does not work....I got right ID from echo but Unknown command getEyeVector and getEyePoint.

#### Re: GuiCrossHair recognize the subject/item automatically

fLUnKnhaXYU
Posts: 84
Joined: Wed Nov 15, 2017 8:19 am
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 .

#### Re: GuiCrossHair recognize the subject/item automatically

irei1as
Posts: 84
Joined: Fri Feb 27, 2015 5:13 pm
If you're in a single player environment (server=client) you can use the shortcuts
LocalClientConnection.player and LocaClientConnection.camera to get the id for the control player and camera.

Like: (LocalClientConnection.camera).getEyeVector();

But it's only for single player use. Do not use them if you eventually plan on going multiplayer.

#### Re: GuiCrossHair recognize the subject/item automatically

Bishop
Posts: 71
Joined: Wed Dec 09, 2015 2:30 am
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
....so I get it working by mouse cursor...and the trick I used is that RMB is set to display the mouse cursor...so 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 viewer....so 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

#### Who is online

Users browsing this forum: No registered users and 1 guest