- Home /
Dumb this down for me?
I know a little programming with c# I found this in a youtube video and i learn better when things are dumbed down for me. I dont know what a Quaternium is (Idk how to spell, matf.abs, euluer angles and a float.help me please?
using UnityEngine; using System.Collections;
[RequireComponent(typeof(CharacterController))]
public class PlayerController : MonoBehaviour {
// Handling
public float rotationSpeed = 450;
public float walkSpeed = 5;
public float runSpeed = 8;
//System
private Quaternion targetRotation;
// Components
private CharacterController controller;
void Start () {
controller = GetComponent<CharacterController>();
}
void Update () {
Vector3 input = new Vector3(Input.GetAxisRaw ("Horizontal"),0, Input.GetAxisRaw ("Vertical"));
if (input != Vector3.zero) {
targetRotation = Quaternion.LookRotation (input);
transform.eulerAngles = Vector3.up * Mathf.MoveTowardsAngle(transform.eulerAngles.y,targetRotation.eulerAngles.y,rotationSpeed * Time.deltaTime);
}
Vector3 motion = input;
motion *= (Mathf.Abs (input.x) == 1 && Mathf.Abs (input.z) == 1)?.7f:1;
motion *= (Input.GetButton("Run"))?runSpeed:walkSpeed;
motion += Vector3.up * -8;
controller.Move(motion * Time.deltaTime);
} }
Answer by Graham-Dunnett · Feb 17, 2014 at 08:51 PM
Quaternion - a way to represent rotation
Mathf.Abs
- convert a number to positiveEuler angles - another way to represent rotation
Float - a way to represent real numbers
Google and/or wikipedia are good learning resources.
Thanks, also I need an explanation for the code above.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Multiply float by int? 2 Answers