Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Enemy movement on uneven 3D terrain

$
0
0
When an Enemy in my game (RPGish) becomes aware of the player and gives chase, it falls through the terrain if there's a height difference (uneven/hilly terrain); Enemy has Character Controller/Motor but no Rigidbody. I was using this: myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime; I have read that manipulation of the transform.position is common with object fall throughs. After many attempts, I ended up with this: CharacterController cc = GetComponent(); Vector3 forward = transform.TransformDirection(Vector3.forward); cc.SimpleMove(forward * moveSpeed * Time.deltaTime); and my Enemy has stopped falling through the ground. I changed moveSpeed from 4 (with failed/fall through code) to 299 to make it approx. the same speed and, to be honest, I have no idea why. Have I done something unexpected that will cause me headaches later with this movement code? Is there a standard practice for moving an AI unit around on uneven terrain?

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>