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

Creating a teleportation gun

$
0
0
Hi, I've been trying to create a teleportation gun using raycasts and rigidbody's. I have made a basic raycast gun var bullet : Rigidbody; var bulletPoint : Transform; function Update () { var hit : RaycastHit; if (Input.GetButtonDown("Fire1")) { var fwd = transform.TransformDirection (Vector3.forward); if (Physics.Raycast (transform.position, fwd)) print ("Raycast Hit!"); else print ("Raycast Didn't Hit!"); var bulletInstance : Rigidbody; bulletInstance = Instantiate(bullet, bulletPoint.position, bulletPoint.rotation); //Object to clone, origin of bullet, rotation bulletInstance.AddForce(fwd * 500); //Moving projectile Quaternion.LookRotation(hit.normal)); } } I also have a basic teleport script: var target : Transform; function Update () { } function OnTriggerEnter (col : Collider) { if(col.gameObject.tag == "teleport") { this.transform.position = target.position; } } I'm trying to combine these two, so when the projectile hits a wall, it teleports the player to where it hit. Any help is greatly appreciated.

Viewing all articles
Browse latest Browse all 18

Latest Images

Trending Articles



Latest Images