- Home /
My vehicle wont perform both the Tilt and Turn
Hello, I need to comment out calling the tilt() function from the script in order to have the turn() function work properly but for some reason if I call both....neither the turn() nor tilt() work
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour {
// Use this for initialization
public float speed;
public float turnspeed;
public float tiltamt;
private Vector3 movement;
private Rigidbody player;
float v;
float h;
void Start () {
player = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update () {
v = Input.GetAxis("Vertical");
h = Input.GetAxis("Horizontal");
}
private void FixedUpdate()
{
Move();
turn();
tilt();
}
private void Move()
{
movement = transform.forward * speed * Time.deltaTime * -v;
player.MovePosition(transform.position + movement);
}
private void turn()
{
float turn = h * turnspeed * Time.deltaTime;
Quaternion rotation = Quaternion.Euler(0.0f, turn, 0.0f);
player.MoveRotation(transform.rotation * rotation);
}
private void tilt()
{
Quaternion tilt = Quaternion.Euler(0.0f, 0.0f, tiltamt * h * Time.deltaTime);
player.MoveRotation( tilt);
}
}
My current aim is to basically have a rough model of a plane tilt towards the direction it is turning . Any help is appreciated.
Comment
Your answer
Follow this Question
Related Questions
How to get moving player to tilt when turning 0 Answers
Tilt Function. HELP! 1 Answer
Tilt with rotation. 0 Answers
Bank Camera Based On Rotation Delta 1 Answer
Move object to position, perform action, move back to starting position 0 Answers