I would really like to see what it is doing in there so I can create my own method. I am so tired of this function being essentially useless.
Anyone have the source for the transform.LookAt() function?
[10172-wall.zip|10172]
I would really like to see what it is doing in there so I can create my own method. I am so tired of this function being essentially useless.
Anyone have the source for the transform.LookAt() function?
[10172-wall.zip|10172]
The solution was staring me in the face the whole time…
Vector3 PlanarUp = Vector3.Cross((Vector3.zero - WallBones[1].position).normalized,(Vector3.zero - WallBones[0].position).normalized);
WallBones[0].localRotation = Quaternion.LookRotation((Vector3.zero - WallBones[0].position).normalized,PlanarUp);
WallBones[1].localRotation = Quaternion.LookRotation((Vector3.zero - WallBones[1].position).normalized,PlanarUp);
All I had to do was find the correct up vector from the plane created by the 3 points. Done and Done.
– Cyber_DefectI don# t have time to look at more results for you online, but there are many example googling the right search terms might reveal code written in Python or c or a reference of some kind.
What I was saying is that instead of rewriting the function because it would be too complicated for me, I would probably try deconstructing it so that I know all the information it provides on the different axes compared to all the information from the starting axes and be able to use a mix of both in the final result
Why do you think it's "useless"? It does exactly what it's supposed to do.
– Eric5h5Zoom, I know how it functions, hence my calling it useless. My problem is that I want to make a function that works similarly without reinventing the wheel.
– Cyber_DefectWhydoIdoIt, there is an overloaded method of Quaternion.lookRotation() that uses the up vector. Is there some way to define the up vector maybe? Maybe as a function of X and Y? to make it perpendicular I mean...
– Cyber_Defectcheers for the heads up on the lookrotation. i had this problem when i was making geodesic domes, i had to lookat 12 objects to the centre and control their rotation to be perfectly aligned. once you have 2 rotations as in lookrotation... you mathematically have all the others because it leaves no ambiguity in your code, just control which axis is rotated by flipping with subsequent rotations. what i am saying is... you can choose the axis by flipping 90 degrees along x or y or z after the function call.
– MountDoomTeamG'd sorry Cyber, don't know how I missed all your comments on here - my spam filter must be trashing Unity emails again. Yes the benefit of LookRotation compared to setting transform.forward is that you can control the rotation around the axis that is looking forward. I'm struggling to get my head around what that is for your case though :)
– whydoidoit