Question by
DroidifyDevs · Jan 11, 2016 at 10:53 PM ·
scripting problemainavmeshagenttilttilting
How to tilt NavMeshAgent?
Hi there!
So everyone knows it is pretty easy to tilt an object, but how to tilt a NavMeshAgent?
I want the Agent to tilt 20 degrees on Z axis when he hits a tag as seen in this script:
using UnityEngine;
using System.Collections;
public class AItilter : MonoBehaviour {
public float z;
// Use this for initialization
void Start() {
}
// Update is called once per frame
void Update() {
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("lowrightturn"))
{
z += Time.deltaTime * 5;
transform.rotation = Quaternion.Euler(0, 0, z);
}
}
}
However when he hits the tag all he does is spin around and continue. Also I noticed that when tilting the Agent manually in the editor, it doesn't tilt! AND when changing the surface he walks on to being tilted, he goes upright. So apparently I can't tilt while using Unity's AI?
Please help! Thank you so much!
Comment
You can create empty game object with Nav$$anonymous$$eshAgent and put your game object into it. Then you tilt your game object ins$$anonymous$$d of agent. So far I could not find how to tilt the agent directly.