Quantcast
Channel: Latest Questions by Smithy311
Viewing all articles
Browse latest Browse all 18

Optimizing My Teleportation Gun?

$
0
0
Hi, I need to optimize my teleportation gun in a few ways. Is there a way I can make it so that the instantiated object is affected differently to the original object? The gun is also pretty buggy, including where the original bullet spawns. Gun Code: #pragma strict var bullet : Rigidbody; var bulletPoint : Transform; var bulletInstance : Rigidbody; function Update () { var power : int = 500; var hit : RaycastHit; if (Input.GetButtonDown("Fire1")) { var fwd: Vector3 = transform.TransformDirection(Vector3.forward); if (Physics.Raycast (transform.position, fwd))//Check if raycast hit print ("Raycast Hit!"); else print ("Raycast Didn't Hit!"); var bulletInstance: Rigidbody = Instantiate(bullet, transform.position, transform.rotation) as Rigidbody; //Object to clone, origin of bullet, rotation bulletInstance.AddForce(fwd * power); //Moving projectile Quaternion.LookRotation(hit.normal); } } Teleport Script: var target : Transform; function OnTriggerEnter( col : Collider ) { player = GameObject.Find("Player"); if(col.gameObject.tag == "teleport") { player.transform.position = target.position; } } Preview: http://i.imgur.com/QR7ESdZ.png Any optimization help would be great.

Viewing all articles
Browse latest Browse all 18

Latest Images

Trending Articles



Latest Images

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