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);
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.