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

Floating enemy objects?

$
0
0
void Patrol() { RaycastHit rayHit; if (Physics.Raycast (transform.position, Vector3.back, out rayHit, 10.0f)) { if(rayHit.collider.tag == "Player") { playerSpotted = true; } } moveDist = speed * Time.deltaTime; Vector3 posDir = AINodePoints [curIndex].transform.position - transform.position; Vector3 rotDir = Vector3.RotateTowards (transform.forward, posDir, moveDist, 0.0f); transform.position = Vector3.MoveTowards (transform.position, AINodePoints [curIndex].transform.position, moveDist); transform.rotation = Quaternion.LookRotation (rotDir); if (transform.position == AINodePoints [curIndex].transform.position) { Debug.Log ("I am at node: 1"); curIndex = 1; } if (transform.position == AINodePoints [curIndex].transform.position) { Debug.Log ("I am at node: 0"); curIndex = 0; } Debug.DrawRay (transform.position, rotDir, Color.red); } ^Current movement script for my enemy. It works great, until it sees the player. In which case he becomes superman and flies towards the player object. Now I tried adding Rigidbody before. But I was having a huge issue recreating the same type of movement for Rigidbody. So is there a way I can keep the enemy object on the ground?

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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