public static void FirstPersonTouchScreenControlHandler( float xVelocity, float zVelocity, bool buttonPressed, out Vector3 displacementVector, out Vector3 rotationalVector, Transform transform = null, ActionCallback actionCallback = null, AnimationCallback animationCallback = null) { displacementVector = Vector3.zero; if (transform == null) { rotationalVector = Vector3.zero; } else { rotationalVector = transform.rotation.eulerAngles; } if (animationCallback == null) { animationCallback = DefaultAnimationCallback; } if (actionCallback == null) { actionCallback = DefaultActionCallback; } if (buttonPressed) { actionCallback(); animationCallback(actionAnimation: true); } rotationalVector.y += xVelocity; displacementVector = VectorAnalysis.CalculateDisplacementFromAngle(rotationalVector) * zVelocity; if (displacementVector != Vector3.zero && rotationalVector != transform.rotation.eulerAngles) { animationCallback(travelAnimation: true); } else { animationCallback(idleAnimation: true); } }
public static void FirstPersonControlHandler( out Vector3 displacement, out Vector3 rotation, Transform transform = null, ActionCallback actionCallback = null, AnimationCallback animationCallback = null) { displacement = Vector3.zero; if (transform == null) { rotation = Vector3.zero; } else { rotation = transform.rotation.eulerAngles; } bool action = false; if (animationCallback == null) { animationCallback = DefaultAnimationCallback; } if (actionCallback == null) { actionCallback = DefaultActionCallback; } if (Input.GetKey(Controls.Forward) || Input.GetKey(Controls.ForwardAlt)) { displacement = VectorAnalysis.CalculateDisplacementFromAngle(rotation); animationCallback(travelAnimation: true); } if (Input.GetKey(Controls.Reverse) || Input.GetKey(Controls.ReverseAlt)) { displacement = VectorAnalysis.CalculateDisplacementFromAngle(rotation) * -1; animationCallback(travelAnimation: true); } if (Input.GetKey(Controls.Left)) { rotation.y += -5.0f; } if (Input.GetKey(Controls.Right)) { rotation.y += 5.0f; } if (Input.GetKey(Controls.Space)) { action = true; actionCallback(); animationCallback(actionAnimation: true); } if (displacement == Vector3.zero && !action) { animationCallback(idleAnimation: true); } }