moving a model backwards

Ok i have a model that is exported as .fbx from max, and its backwards in my game.

when i use code to reverse the LookAt the model moves backwards with a Vector3.Forward. if i use Vector3(0,0,-1) it moves sideways :shock:

if Vector3.Forward is moving the object away from the look at i hacked up to change the npcs rotation, how could i get it to move backwards :stuck_out_tongue:

im really stumped on this, could anyone lend a hand?

Couldn’t you just rotate your model 180 degrees from within your 3d modelling program and re-export the fbx? Seems like that would be the easier thing to do. Otherwise if “Vector3.forward” moves the object backward… “-Vector3.forward” should move it backward?

Then again, your coding could get confusing since your translations would be backwards.

yeah i tried to to that to move it backwards but then he moves sideways? but when i just do it normally its as if hes running away cause he moved right back, which made no sense to me. it was like , working more right when he was moving the opposite direction

and for the life of me i cannot figure out how to rotate the model in max 9. i have to rotate every frame, when i rotate it and change to the next frame, the first one i rotated has reverted.

also if i go to mirror XY then it rotates the frame around, but the same issue i cannot get all the frames rotated and exported.

Also, you can try rotating the object 180 degrees using eulerAngles after you do the LookAt.

Like so,

transform.LookAt(target);
// Force the object to rotate 180 about the Y-axis
transform.eulerAngles = new Vector3(transform.eulerAngles.x, 180, transform.eulerAngles.z);

hmm

i tried to rotate the whole object doing that

follower.eulerAngles = new Vector3(follower.eulerAngles.x, 180, follower.eulerAngles.z );

and just the mesh attached to the object,

GameObject.Find(“SLUG”).transform.eulerAngles = new Vector3(GameObject.Find(“SLUG”).transform.eulerAngles.x, 180, GameObject.Find(“SLUG”).transform.eulerAngles.z);

but neither really worked

Can you post the whole script?

private var leader : Transform;
private var follower : Transform;
var rotateFixMe : Transform;
private var followerobj : GameObject;
var npcprefab : GameObject;

var spawnerobj : GameObject;
private var spawnerpos : Vector3;
private var spawnerrot : Quaternion ;

var speed : float = 7.0;
var chaseRange : float = 60.0;
var midRange : float = 33.0;
var closeRange : float = 9.0;
private var range : float;

private var walking = false;
private var running = false;

private var relativePos : Vector3;
private var rot : Quaternion;

function Start()
{
	spawnerpos = spawnerobj.transform.position;
	spawnerrot = spawnerobj.transform.rotation;
	leader = GameObject.Find("PlayerController").transform;
	followerobj = Instantiate(npcprefab, spawnerpos, npcprefab.transform.rotation);
	follower = followerobj.transform;


	// Make sure that forces dont really affect our follower 
	followerobj.rigidbody.isKinematic  = true;
				
	// Set all animations to loop, and stop any that are playing
   followerobj.animation.wrapMode = WrapMode.Loop;
   followerobj.animation.Stop();
}


function FixedUpdate () {
			// Calculate the distance between the follower and the leader.
		range = Vector3.Distance( follower.position,leader.position );

		if ( range <= chaseRange  range >= midRange) {
		
			if (!running) {
				running = true;
				walking = false;
				followerobj.rigidbody.isKinematic  = false;
				followerobj.animation.CrossFade("attack");
			}

		
		 // If the follower is close enough to the leader, then chase!
			follower.LookAt(leader);
			follower.eulerAngles = new Vector3(follower.eulerAngles.x, 180, follower.eulerAngles.z ); 
		  follower.Translate( (speed * 3.15) * Vector3(0,0,1) * Time.deltaTime);
		 // followerobj.rigidbody.AddForce((speed * 30.15) * Vector3.forward);
		}
		
		else if ( range <= midRange  range >= closeRange){
		
			if (!walking) {
				running = false;
				walking = true;
				followerobj.rigidbody.isKinematic  = false;
				followerobj.animation.CrossFade("attack");
			}

		  // If the follower is close enough to the leader, then chase!
	follower.LookAt(leader);
	GameObject.Find("SLUG").transform.eulerAngles = new Vector3(follower.eulerAngles.x, 180, follower.eulerAngles.z); 
		  follower.Translate( speed * Vector3(0,0,1) * Time.deltaTime);
		//followerobj.rigidbody.AddForce(speed * Vector3.forward);
	   } 
	   
	   // We have gotten too close  !
	   else if (range >= closeRange) {
			if (walking || running){
				walking = false;
				running = false;
				followerobj.rigidbody.isKinematic  = true;
		// If the follower is close enough to the leader, then chase!
			follower.LookAt(leader);
			rotateFixMe.eulerAngles = new Vector3(follower.eulerAngles.x, 180, follower.eulerAngles.z); 
				followerobj.animation.CrossFade("attack");
			}
		}
		
		// Out of range?
		else {
			if (walking || running){
				walking = false;
				running = false;
				followerobj.rigidbody.isKinematic  = true;
			follower.LookAt(leader);
			rotateFixMe.eulerAngles = new Vector3(follower.eulerAngles.x, 180, follower.eulerAngles.z); 
				followerobj.animation.Stop();
			}
		}
}

i try two different methods, one in chase and on in walking. neither work.

follower is the transform of the slug monster, but SLUG (when i do gameobject.find) is just the mesh, or atleast when i rotate that in the ide it rotates the mesh.

and if i rotate it in the ide then it doesnt help at all, ive tried it.

Sadly, i have similiar issues. I end up parenting anything i export out of lightwave to a null object.

When it’s in unity, i can simply rotate the main object to 0,0,0 then adjust the rotation of the null object to whatever will make the object “correct” in unity. Not a perm fix, but might get you by.

i figured it out with this expression

apoint = leader.position;
apoint = 2.0 * follower.position - apoint;
				
follower.LookAt(apoint);

to look in the opposite direction

and i did a -Vector3.forward to move backwards, but in effect, moving my model towards the camera, facing the camera.

yay!

Just change the speed variable to a negative.

did that already :stuck_out_tongue: its working now tho, thanks guys.