Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

Getting the rotation of an object from another object within a prefab.

$
0
0
I'm not really even sure how to go about asking this, but here goes. My overall goal is to make a character's eyes move by adjusting the mainTextureOffset by using the rotation of some bones in the character's eyes as the x and y values. So I am trying to assign a transform variable on a script that I have attached to a character's eyes. Problem is that the character is created from a prefab on start, so I can't simply drop the object in the transform slot. I need to assign the transform through scripting. The eye bone is in the same object as the eye with the texture, but down a different branch of the hierarchy. So how would I access the rotation transform for the eye bone? Here is my script so far. It works as I need it to with the exception of assigning that transform variable. var eyeBone : Transform; function Start () { eyeBone = //Not sure what I need here. } function Update () { var eyeBoneAngleX = eyeBone.transform.localEulerAngles.x; var eyeBoneAngleY = eyeBone.transform.localEulerAngles.y; renderer.material.mainTextureOffset = Vector2(eyeBoneAngleX,eyeBoneAngleY); }

Viewing all articles
Browse latest Browse all 1875

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>