How to stop heading binding to 3d object growing and shrinking
Chris Hughes
Posts: 3
Can someone please tell me how I can stop a 3d object with a head binding growing and shrinking the closer or further away you get from the camera.
I want it to still go left and right but not change in size.
Thanks
0
Comments
-
You can copy the head position and rotation then set the y and z value of the head position to a constant one you control. Then apply this adjusted head position and the rotation to the object you want to track. This will lock it to only being able to move on the x axis (left/right).
If you want it to be able to go up and down as well, then you can just remove the line that says
headPos.y = setY
Here is a script example:
//@input SceneObject trackedObject //@input Component.Head headBinding // set this to false if you want to disable the tracked object rotation too var allowRotation = true // the z depth to set the tracked object to var setDepth = -40 // the y (up/down) value to set the tracked object to var setY = 0 // every frame we update the position of the tracked object function setTransform(){ // get head position var headPos = script.headBinding.getTransform().getWorldPosition() // set the y and z values to our fixed/constant ones headPos.y = setY headPos.z = setDepth // set the trackedObject position to the new pos from adjusted head position script.trackedObject.getTransform().setWorldPosition(headPos) // if rotation is allowed then we set the tracked object's rotation to match the head's if(allowRotation){ var headRot = script.headBinding.getTransform().getWorldRotation() script.trackedObject.getTransform().setWorldRotation(headRot) } } var updateEvent = script.createEvent('UpdateEvent'); updateEvent.bind(setTransform);
0