user interface - Unity3d - How to parent a worldspace GUI to a car? -
how can attach worldspace ui onto car object? i'm using ui image rotational fill speedometer, how attach image car? i've made work setting position , rotation of car, moves it's position when turning, while still being rotated correctly. help? code:
vector3 basepos = relevantparent.transform.position; vector3 tweakedpos = basepos; tweakedpos.x = tweakedpos.x + xoffset; tweakedpos.y = tweakedpos.y + yoffset; tweakedpos.z = tweakedpos.z + zoffset; transform.position = tweakedpos; transform.localrotation = relevantparent.transform.localrotation;
https://docs.unity3d.com/scriptreference/recttransform.html
recttransform, world space canvas has know position, rotation , on, inherits transform.
transform can set parent object.
so grab recttransform worldspace canvas , set it's parent cars transform.
recttransform recttransform; recttransform.parent = transform; //transform of car.
Comments
Post a Comment