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

Enemy Shooting bullet

$
0
0
Well I am making a first person shooting game but it seems like that my enemy only shoots upwards when I set the rotation of the spawn point as zero as well as following programs from youtube channels (e.g. Tornadotwins) and it seems like that they don't work at all. Because I am a newbie towards unity I don't really know how it works so here below is my code and whats wrong with it? var LookAtTarget:Transform; var damp = 1.0; var bullitPrefab:Transform; var savedTime=0; var enemyprojectile = Transform; function Update () { if(LookAtTarget) { var rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, rotate, Time.deltaTime * damp); var seconds : int = Time.time; var oddeven = (seconds / 2); if (oddeven) { Shoot(seconds); } } } function Shoot(seconds) { if (seconds!=savedTime); { var bullit = Instantiate(bullitPrefab ,transform.Find("Spawn2").transform.position , Quaternion.identity); bullit.gameObject.tag = "enemyprojectile"; bullit.rigidbody.AddForce(transform.forward * 1000); savedTime=seconds; } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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