Hi there.
This is the third time I’m writing this post as first time DNS server crashed when I posted it, resulting in loss of all text, second time I’ve lost electricity… Let’s hope this one goes through!
I’m posting here as last straw to find solution.
This means that I have googled and tried many different solutions that work for others. None works for me.
I have problem with LookAt rotations.
I’m using sample AI wander script that I’ve found here :
#pragma strict
var Speed= 10;
var wayPoint : Vector3;
function Start(){
//initialise the target way point
Wander();
}
function Update()
{
transform.position += transform.TransformDirection(Vector3.forward)*Speed*Time.deltaTime;
if((transform.position - wayPoint).magnitude < 3)
{
// when the distance between us and the target is less than 3
// create a new way point target
Wander();
}
}
function Wander()
{
// does nothing except pick a new destination to go to
wayPoint= Random.insideUnitSphere *5;
wayPoint.y = 0.5;
// don't need to change direction every frame seeing as you walk in a straight line only
transform.LookAt(wayPoint);
Debug.Log(wayPoint + " and " + (transform.position - wayPoint).magnitude);
}
Now, I have an AI model of stick figure that stands on the ground. Once script runs it rotates that gameObject wrong so it looks like character is lying in the air…
Simple solution would be to parent this gameObject, but that’s not exactly what I’m looking for because I will have many different AI characters wandering around, each one of them having same/similar/modified script attached.
I googled for hours and tried many solutions but none really helped :
I tried to adjust all codes found on those links but I couldn’t make it work. (Tried Quaternion as well) No matter what I did I would end up with that weird rotation.
I’m also having this problem in my “Click to move” script, that I picked up from web and modified. But I handled that with parent, tho for sure I would like to fix it properly.
But nevermind that, If we manage to find solution for this issue I might find other one myself Used this script just for an example.
Thanks !