- Home /
NPC code, works great, besides them being in the ground.
Alright, this is a code I picked up from some random asset or another and it works great, besides the fact that the character is halfway in the ground.
void LateUpdate ()
{
transform.position = new Vector3 (transform.position.x, Terrain.activeTerrain.SampleHeight (transform.position), transform.position.z);
}
}
I'm POSITIVE that this line of code is what needs to be changed to add a certain amount of height to the position, specifically the Y coordinate spot. Let me know your thoughts on this
Also, this is with no other script in the object whatsoever, besides animations. And it's ignored all attempts to affect it with colliers and rigid bodies. Anyone have some advice on this? Might be an issue later.
-Sir Paddles of Loxely
so the character ignores everything but the terrain essentially. anyone got a bright idea on how to trim this code to only contain the wander/follow functionality and leave the positioning up to a mesh controller?
Answer by Sir_Paddles · Feb 01, 2013 at 09:41 AM
Alright so, I dumped that one. Navigate here http://www.stevegargolinski.com/some-simple-ai-behaviors-in-unity/
if you need some basic AI scripts to get an idea of whats going on.
Answer by Ninita · May 10, 2013 at 12:18 PM
See this link http://forum.unity3d.com/threads/181705-GroundNPC?p=1241872#post1241872 . I hope this help