c# - My pivot point does not follow my gameobject -
so im making unity game have gameobject im moving , rotation during game, thing pivot point doesnt stick object. rotates fine on spot when game begins when has been moved the pivotpoint didnt follow , still rotation around start location. im using "extra" gameobject pivotpoint in right spot in first place, object attached first object tho should follow around.
any ideas cause/solution this? im pulling out hair here been moving stuff around night >.<
here basic code rotating, doubt thats though.
public float speed = 1f; // use initialization void start () { } // update called once per frame void update () { if (input.getkey(keycode.w)) // gå fremad { transform.position -= new vector3 (speed * time.deltatime, 0.0f, 0.0f); } if (input.getkey(keycode.s)) // gå baglæns { transform.position += new vector3 (speed * time.deltatime, 0.0f, 0.0f); } if (input.getkey(keycode.q)) // strafe mod venstre { transform.position -= new vector3 (0.0f, 0.0f, speed * time.deltatime); } if (input.getkey(keycode.e)) // strafe mod højre { transform.position += new vector3 (0.0f, 0.0f, speed * time.deltatime); } if (input.getkey(keycode.d)) // drej mod venstre { transform.rotatearound (vector3.zero, vector3.up, 20 * time.deltatime); } if (input.getkey(keycode.a)) // drej mod højre { transform.rotatearound (vector3.zero, vector3.up, -20 * time.deltatime); }
don't use:
transform.rotatearound(vector3.zero, vector3.up, 20 * time.deltatime);
if use this, rotate around vector 0 - (0,0,0) - in world coordinate system (not local).
if want rotate object around own center use:
transform.rotate( xangle, yangle, zangle, relativeto );
if want rotate object relative object (i don't think want that), anyway:
transform.rotatearound(othergameobject.transform.position, vector3.up, 20 * time.deltatime);
Comments
Post a Comment