Created
October 16, 2016 01:56
-
-
Save Sammyjroberts/0f6d8caa8981a55c0a67087d8311c935 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Ray camRay = Camera.main.ScreenPointToRay (Input.mousePosition); | |
RaycastHit floorHit; | |
if(Physics.Raycast (camRay, out floorHit, camRayLength, floorMask)) | |
{ | |
// Create a vector from the player to the point on the floor the raycast from the mouse hit. | |
Vector3 playerToMouse = floorHit.point - ssr.transform.position; | |
// Ensure the vector is entirely along the floor plane. | |
playerToMouse.y = 0f; | |
ssr.transform.position = floorHit.point+(transform.position-floorHit.point)/2; | |
var scale = (ssr.transform.position-floorHit.point).magnitude; | |
Debug.Log(scale); | |
var length = scale*2; | |
if(length > 6) { | |
length = 6; | |
} | |
ssr.transform.localScale = new Vector3(length,1,0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment