-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f803ea
commit ed08d1f
Showing
8 changed files
with
429 additions
and
164 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class LaserGrapple : MonoBehaviour { | ||
|
||
|
||
LineRenderer laserLine; | ||
public Transform startPoint; | ||
public Transform endPoint; | ||
public Camera fpsCam; | ||
public float impactForce = 100f; | ||
public float range = 100f; | ||
private Player player; | ||
private Vector3 lastPosition; | ||
private Rigidbody hitRigidbody; | ||
|
||
// Use this for initialization | ||
void Start () { | ||
laserLine = GetComponent<LineRenderer>(); | ||
//laserLine.SetWidth(.2f, .2f); | ||
player = transform.root.GetComponent<Player>(); | ||
|
||
} | ||
|
||
// Update is called once per frame | ||
void Update () { | ||
|
||
if (Input.GetButton("Fire2")) | ||
{ | ||
//player.playerController.SetHitAttraction(hit.point); | ||
if (Input.GetButtonDown("Fire2")) | ||
{ | ||
|
||
|
||
RaycastHit hit; | ||
if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range)) | ||
{ | ||
|
||
|
||
|
||
|
||
if (hit.transform.GetComponent<Rigidbody>() != null) | ||
{ | ||
hit.transform.GetComponent<Rigidbody>().AddForce(hit.normal * impactForce); | ||
hitRigidbody = hit.transform.GetComponent<Rigidbody>(); | ||
|
||
} | ||
else | ||
{ | ||
hitRigidbody = null; | ||
} | ||
player.playerController.SetHitAttraction(hit.point); | ||
laserLine.enabled = true; | ||
laserLine.SetPosition(0, startPoint.position); | ||
laserLine.SetPosition(1, hit.point); | ||
lastPosition = hit.point; | ||
|
||
} | ||
else | ||
{ | ||
laserLine.enabled = false; | ||
} | ||
} | ||
else{ | ||
laserLine.SetPosition(0, startPoint.position); | ||
if (hitRigidbody == null) | ||
{ | ||
|
||
player.playerController.SetHitAttraction(lastPosition); | ||
} | ||
else | ||
{ | ||
|
||
player.playerController.SetHitAttraction(hitRigidbody.position); | ||
laserLine.SetPosition(1, hitRigidbody.position); | ||
} | ||
|
||
} | ||
|
||
} | ||
else | ||
{ | ||
laserLine.enabled = false; | ||
} | ||
} | ||
|
||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
m_EditorVersion: 2017.3.1f1 | ||
m_EditorVersion: 2017.4.0f1 |