Last active
February 17, 2018 20:29
-
-
Save tomazsaraiva/b4973883117b415b9ed0a150a6e9ac06 to your computer and use it in GitHub Desktop.
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
Vector2 screenCenterPoint = new Vector2(Screen.width/2, Screen.height/2); | |
_ray = Camera.main.ScreenPointToRay(screenCenterPoint); | |
if(Physics.Raycast(_ray, out _hit, Camera.main.farClipPlane) && _bulletHole != null) | |
{ | |
Vector3 bulletHolePosition = _hit.point + _hit.normal * 0.01f; | |
Quaternion bulletHoleRotation = Quaternion.FromToRotation(-Vector3.forward, _hit.normal); | |
GameObject hole = GameObject.Instantiate(_bulletHole, bulletHolePosition, bulletHoleRotation); | |
hole.transform.SetParent(_hit.transform); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment