Game Development Reference
In-Depth Information
Transform
X : 1037.5 , Y : 4 , and Z : 693
Position
X : 0 , Y : 36 , and Z : 0
Rotation
X : 1 , Y : 1 , and Z : 1
Scale
5. Now, we will add a script that makes this Wall object break apart when the char-
acter shoots at it. Let's go to the Chapter7/Scripts/C#/Object (for C#
users) or Chapter7/Scripts/Javascript/Object (for Unity JavaScript
users) folder, and double-click on the rocket script to open this script in the
script editor.
6. In the rocket script, we will add two parameters at the beginning of the script,
as highlighted in the following code:
// Unity JavaScript user:
var explosionParticle : GameObject;
var explosionRadius : float = 50;
var explosionForce : float = 1000;
//C# user:
public GameObject explosionParticle;
public float explosionRadius = 50;
public float explosionForce = 1000;
7. Next, we will go to the OnCollisionEnter() function and add the following
highlighted script:
// Unity JavaScript user:
function OnCollisionEnter (others : Collision) {
var contactPoint : ContactPoint =
others.contacts[0];
var rotation : Quaternion =
Quaternion.Euler(Vector3.up);
Search WWH ::




Custom Search