Quantcast
Channel: Questions in topic: "gun"
Viewing all articles
Browse latest Browse all 592

RayCast Shooting not working

$
0
0
Hi, I am new to unity this year, and have been having problems with the raycast shooting script. When I play my game, it spawns the effect, but it only spawns in the middle of map. I have had another game without terrain that the raycast worked perfectly. Is terrain the problem? ![alt text][1] Here is my script: #pragma strict var Effect : Transform; var TheDammage = 100; function Update () { var hit : RaycastHit; var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5, 0)); if (Input.GetMouseButtonDown(0)) { if (Physics.Raycast (ray, hit, 100)) { var particleClone = Instantiate(Effect, hit.point, Quaternion.LookRotation(hit.normal)); Destroy(particleClone.gameObject, 2); hit.transform.SendMessage("ApplyDammage", TheDammage, SendMessageOptions.DontRequireReceiver); } } } [1]: /storage/temp/35514-raycast+shooting+not+working.png

Viewing all articles
Browse latest Browse all 592

Trending Articles



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