Created
March 29, 2011 23:21
-
-
Save tracend/893555 to your computer and use it in GitHub Desktop.
Unity3D: Simple shooting function - Source: http://wiki.dreamsteep.com/Unity3d
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
var prefabBullet: Transform; | |
var shootForce: float ; | |
function Update () { | |
if(Input.GetButtonDown("Shoot") ) | |
{ | |
var instancebullet =Instantiate( prefabBullet ,transform.position,Quaternion.identity); | |
instancebullet.rigidbody.AddForce(transform.forward * shootForce); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment