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
object.rigidbody.velocity += (centerax.transform.position - object.transform.position).normalized * 10 * Time.deltaTime; |
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
var target : Transform; | |
// Rotate the camera every frame so it keeps looking at the target | |
function Update() { | |
transform.LookAt(target); | |
} |
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
function Update() { | |
if ( Vector3.Distance( enemy.position, transform.position ) < 10 ) | |
print("I sense the enemy is near!"); | |
} |
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
// Make the script also execute in edit mode. | |
@script ExecuteInEditMode() | |
// Just a simple script that looks at the target transform. | |
var target : Transform; | |
function Update () { | |
if (target) | |
transform.LookAt(target); | |
} |
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
function OnGUI () { | |
if (GUI.Button (Rect (25, 25, 100, 30), "Quit")) { | |
Application.Quit(); | |
} | |
} |
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
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); | |
} |
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
function Update () { | |
// Move the object 10 meters per second! | |
var translation : float = Time.deltaTime * 10; | |
transform.Translate (0, 0, translation); | |
} |
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
function Update () { | |
var someNumber = groundtrigger.triggered; | |
var string= someNumber.ToString(); | |
guiText.text = string; //typeof (groundtrigger.triggered); | |
} |
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
var par : ParticleEmitter; | |
var damage = 2; | |
function Update () { | |
var hit : RaycastHit; | |
// Use Screen.height because many functions (like this one) start in the bottom left of the screen, while MousePosition starts in the top left | |
var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Input.MousePosition.x, Screen.height - Input.MousePosition.y,0)); | |
if (Input.GetMouseButtonDown(0)) { |
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
//My First Unity tool , it will shooot stuff , Keith Legg Jan 24 | |
//to use drag this script to the main camera (or a vehicle's transform node ) , then drag a prefab to the bullet channel on the right | |
//be sure to adjust force/rate of fire so bullets dont hit each other when instantiated (example: higher force = slower the rate) | |
//space bar will fire gun on positive Z axis | |
//for a good default try 1000 force , 3 shots , and .1 second delay | |
var bullet: Transform; | |
var shootForce: float ; | |
var fullauto: boolean = true; |
OlderNewer