#how to scan object that player looking at
1 messages · Page 1 of 1 (latest)
Okay. What's the problem?
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
Look at? So you want to get a reference of the object that the player is looking at?
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.
some exampleee?
Google it. There are plenty of examples of raycasting.
yeah but i mean theres pretty much of excessive code
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.
how i stop raycast after hitting first thing
Umm... A regular raycast only returns one hit(the first thing that it hit), so I'm not sure what you mean by that.
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
It fires as many times as you call it.
Yes it does.
Not sure what you mean by "mass optimization".
Nor what that has to do with mass or optimization.
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
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.
so one big object better than 2 small objects