- Home /
Question by
invulse · Dec 19, 2010 at 05:27 PM ·
ioscharactercontrollermovesimplemove
SimpleMove not working on iOS?
I have multiple characters using charactercontroller's that are being moved with SimpleMove() which works perfect on the desktop. However when built to my iPhone the characters will not move. I have traced out my direction vector on the iOS and the numbers are the same as desktop, just SimpleMove() seems to not work. I also changed SimpleMove() to Move() and that characters now move and by multiplying Time.deltaTime with my direction it seems to work the same way as SimpleMove() but is this a bug in Unity3 and iOS or could there be something else I am doing wrong?
public void MoveTowards (Vector3 position) {
Vector3 direction = position - transform.position;
direction.y = 0;
if (direction.sqrMagnitude < 0.2F*0.2F) {
Stop ();
controller.SimpleMove(Vector3.zero);
return;
}
// Rotate towards the target
transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.LookRotation(direction), rotationSpeed * Time.deltaTime);
transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);
// Modify speed so we slow down when we are not facing the target
Vector3 forward = transform.TransformDirection(Vector3.forward);
float speedModifier = Vector3.Dot(forward, direction.normalized);
speedModifier = Mathf.Clamp01(speedModifier);
// Move the character
if (controller) {
direction = forward * speed * speedModifier*speedModifier;
controller.SimpleMove(direction);
//controller.Move(direction*Time.deltaTime);
} else {
direction = forward * speed * speedModifier*speedModifier;
transform.Translate (direction*Time.deltaTime,Space.World);
}
}
Comment