unity3d - Rotate an object to face an opposite direction -


i have object , b. when click on object b, rotates object b (a faces b). b doesn't face a. need following : when faces b, need face opposite direction. have code rotating @ b. how rotate face opposite direction after that?

vector3 targetdirection = target - transform.position; float step = speed * time.deltatime; vector3 newdirection = vector3.rotatetowards (turretdome.transform.forward, targetdirection, step, 0.0f); turretdome.transform.rotation = quaternion.lookrotation (newdirection); 

you object facing object b, want inverse direction of object after that?

objecta.transform.rotation = quaternion.inverse(objecta.transform.rotation) 

but lets assume example turretdome object a, (negate direction):

turretdome.transform.rotation = quaternion.lookrotation (-newdirection); 

naturally, both of these snippets not show how smoothen rotation, seem know how use time.deltatime.

just incase unsure, quaternion.lerp this


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

php - Doctrine: No alias was set before invoking getRootAlias() error -