- Home /
Objects jump when game is started
I am working on a basic game and I am trying to get the two characters to pathfind to each others base. The issue comes when I press play and the characters suddenly jump up and rotate in an odd way. A video of it happing is here. I created the model in magica voxel and imported it via the export as obj function. The code that the AI is using is below:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class IBasicFighter : MonoBehaviour {
public Transform goal;
private NavMeshAgent agent;
void Start() {
agent = GetComponent<NavMeshAgent>();
agent.SetDestination(goal.position);
}
void Update() {
}
}
Edit: It appers that the obj file that I import does not center the model, as when I create a prefab and center it, the model appers up and to the right
This happens for mainly two reasons.
1) The navmesh you have bakes is above the ground. or 2) the height offset of your navmesh agent is higher than the required.
Try tweaking both the values and see which works for you.
Your answer

Follow this Question
Related Questions
AI Model falls to the ground 2 Answers
Transform an object in other 2 Answers
Character Animation won't work with FPS scripts 1 Answer
Making a first person rpg enemy AI 2 Answers
Check if object without NavMeshAgent component is under navmesh 1 Answer