void Update() { forwardVector = transform.up; float translation = Input.GetAxis("Vertical") * speed; float rotation = Input.GetAxis("Horizontal") * rotationSpeed; translation *= Time.deltaTime; rotation *= Time.deltaTime; //transform.Translate(0, translation, 0); transform.position = HolisticMath.Translate(transform.position, forwardVector, translation); //transform.Rotate(0, 0, -rotation); bool clockwise = false; if (rotation > 0) { clockwise = true; } // Always try to be sure if you are working with degrees or radians. // Dont just divide the rotationSpeed by something. // In this case, Rotate recieves angle in radians, so the conversion is necessary. transform.up = HolisticMath.Rotate(new Coords(forwardVector), Mathf.Abs(rotation) * Mathf.Deg2Rad, clockwise).ToVector(); }
void Update() { float translation = Input.GetAxis("Vertical") * speed; float rotation = Input.GetAxis("Horizontal") * rotationSpeed; translation *= Time.deltaTime; rotation *= Time.deltaTime; // transform.Translate(0, translation, 0); //move towards world up. //need to convert to local space. Vector3 direction = new Vector3(0, translation, 0); Vector3 facingDirection = transform.up; // what is the move direction of the tank Vector3 currentPos = transform.position; transform.position = HolisticMath.Translate(new Coords(0, translation, 0), new Coords(currentPos.x, currentPos.y, currentPos.z), new Coords(facingDirection.x, facingDirection.y, facingDirection.z)).ToVector(); // transform.Rotate(0, 0, -rotation); Vector3 temp = transform.up; float angleInRadians = rotation * Mathf.Deg2Rad; transform.up = HolisticMath.Rotate(new Coords(temp.x, temp.y, temp.z), angleInRadians, true).ToVector(); }
void Start() { Coords position = new Coords(point.transform.position, 1); point.transform.position = HolisticMath.Translate(position, new Coords(new Vector3(translation.x, translation.y, translation.z), 0)).ToVector(); }
void Update() { float translation = Input.GetAxis("Vertical") * speed; float rotation = Input.GetAxis("Horizontal") * rotationSpeed; translation *= Time.deltaTime; rotation *= Time.deltaTime; transform.position = HolisticMath.Translate(new Coords(transform.position), new Coords(transform.up), new Coords(0, translation, 0)).ToVector(); transform.up = HolisticMath.Rotate(new Coords(transform.up), rotation * Mathf.Deg2Rad, true).ToVector(); }
// Start is called before the first frame update void Start() { Vector3 c = new Vector3(center.transform.position.x, center.transform.position.y, center.transform.position.z); foreach (GameObject point in points) { Coords pos = new Coords(point.transform.position, 1); pos = HolisticMath.Translate(pos, new Coords(new Vector3(-c.x, -c.y, -c.z), 0)); pos = HolisticMath.Rotate(pos, angle.x, true, angle.y, true, angle.z, true); point.transform.position = HolisticMath.Translate(pos, new Coords(new Vector3(c.x, c.y, c.z), 0)).ToVector(); // point.transform.position = HolisticMath.Translate(pos, // new Coords(new Vector3(translation.x,translation.y,translation.z),0)).ToVector(); // pos = HolisticMath.ScaleTransForm(pos,scale.x,scale.y,scale.z); // point.transform.position = HolisticMath.Translate(pos, // new Coords(new Vector3(c.x,c.y,c.z),0)).ToVector(); } }
// Start is called before the first frame update void Start() { Vector3 c = new Vector3(center.gameObject.transform.position.x, center.gameObject.transform.position.y, center.gameObject.transform.position.z); foreach (GameObject p in points) { Coords position = new Coords(p.transform.position, 1); //p.transform.position = HolisticMath.Translate(position, // new Coords(new Vector3(translation.x, translation.y, translation.z), 0)).ToVector(); position = HolisticMath.Translate(position, new Coords(new Vector3(-c.x, -c.y, -c.z), 0)); position = HolisticMath.Scale(position, scaling.x, scaling.y, scaling.z); p.transform.position = HolisticMath.Translate(position, new Coords(new Vector3(c.x, c.y, c.z), 0)).ToVector(); } }