#how to scan object that player looking at

1 messages · Page 1 of 1 (latest)

ebon wraith
#

i need make own custom function that will get objects by their colliders

quick saffron
#

Okay. What's the problem?

ebon wraith
#

i mean udon already has function for that

#

but

#

it requires me put script on every object that i want to be detected

#

so like 10k objects

#

and i want instead hold it in just one controller script

#

that will scan object by collider

#

object that player looks at

quick saffron
#

Look at? So you want to get a reference of the object that the player is looking at?

ebon wraith
#

or more exactly pointing at

#

because in vr its from hands

#

not head

quick saffron
#

Well, that's pretty simple: just cast a ray from the camera and the hit would contain a reference to the collider/GameObject.

#

Or from the hands

#

From whatever you want to point at things.

ebon wraith
#

some exampleee?

quick saffron
#

Google it. There are plenty of examples of raycasting.

ebon wraith
#

yeah but i mean theres pretty much of excessive code

quick saffron
#

Well, that's something you've gotta learn to deal with. Only use the parts that are useful for you.

#

The docs page would usually only have relevant examples, so look at the docs as well.

ebon wraith
#

how i stop raycast after hitting first thing

quick saffron
ebon wraith
#

okay i found out

#

somehow it fires multiple times

#

also i thought it only stops at colliders

#

and about mass optimization

#

would it be better to use very stretched objects or very tiny ones but 2x more of them

quick saffron
quick saffron
quick saffron
quick saffron
ebon wraith
#

like

#

every object on map has 2 attached objects with script for teleporting above and and below it

#

but i could instead stretch it across all size of object and to point out from both sides

#

and it would be just 1 object with 1 script that would just scan for player position

#

and based on it teleport either up or down

#

but no idea if stretched texture would lag more

quick saffron
#

What you mean is that you scale one object up instead of using 2 objects?
Obviously less objects to render means less render calls = better performance. There's no performance impact from scaling objects.

ebon wraith
#

so one big object better than 2 small objects