Game Development Reference
In-Depth Information
Fig 2.31 A stack of duplicated cubes,
all with Rigidbodies.
Step 13. In the Project, create a new JavaScript file and call it fire .
Open it in the script editor and enter the code in Listing 2.12 . Save
the script and attach it to the Main Camera.
Listing 2.12 Script to Create a Sphere as a Projectile
on a Left Mouse Click
function Update ()
var ray:Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var sphere:GameObject =
sphere.transform.position = ray.origin;
sphere.AddComponent ("Rigidbody");
sphere.rigidbody.AddForce(ray.direction * 1000);
Search Nedrilad ::

Custom Search