Hello. Can someone help me to have a script to work like this :
When button UI is clicked then GameObject Z rotation changed to 0. Anyone can help me?
Thanks!
Tassilo ![]()
Hello. Can someone help me to have a script to work like this :
When button UI is clicked then GameObject Z rotation changed to 0. Anyone can help me?
Thanks!
Tassilo ![]()
Anyone here?
You can do this with Quaternions and / or a new Vector3
Oh. Can you write a script for me? I do not know how to do that… Thanks!
Terraya? Still there?
Her ya go simple stuff
this is the code to change a local object on a Main game object :
for example in this code below stopped the model and animations wondering from the main game object.
modelobj.transform.localScale = new Vector3 (1,1,1);
modelobj.transform.localPosition = new Vector3(0,0,0);
modelobj.transform.localEulerAngles = new Vector3(0,0,0);
this is the code to change the main game object :
transform.eulerAngles = new Vector3(0, float.Parse(newRotation), 0);
transform.position = Vector3.Lerp(transform.position, newPosition, speed * Time.deltaTime);
Lerp helps u slide the object into position as opposed to snapping it to a location or rotation.
Time.deltaTime shouldn’t be used with any/all Lerp functions; the third parameter should be a value between 0 & 1. Lerp doesn’t move from one value to another over-time, rather it uses the third parameter as the percentage between the two values, where:
You probably want to use Vector3.MoveTowards instead.
@OP:
This is really all you need to do to reset the z-rotation of an object:
void ResetRotationZ() {
Vector3 eulers = transform.eulerAngles;
transform.rotation = Quaternion.Euler(eulers.x, eulers.y, 0f);
}
Can someone do a complete script for me? I don’t even know how to code…
I don’t even know how to code…
Maybe it is time to start learning C# basics?.
There are several websites and YouTube series.
Simply google: “C# beginner tutorials” and you’ll find several tutorials.
You can’t be more entitled than this… Maybe you should slow down on the quirky images and try doing things yourself a bit…
Entitled or not, don’t necro pls. Necro + rant because someone annoys you. My god, that’s even more annoying.
As above, please don’t necro posts. This post was made over 2 years ago!
This was your first post; hopefully you’ve come here to do more than this.
See: Community Code of Conduct (1i)
Thanks.