Sample+Scripts

> CopyTransformsRecurse(transform, deadModel); > > create an effect to let the player know he beat the enemy > var effect : Transform = Instantiate(explosionPrefab, transform.position, transform.rotation); > effect.parent = deadModel; > > fall away from the player, and spin like a top > var deadModelRigidbody = deadModel.rigidbody; > var relativePlayerPosition = transform.InverseTransformPoint(Camera.main.transform.position); > deadModelRigidbody.AddTorque(Vector3.up * 7); > if (relativePlayerPosition.z > 0) > deadModelRigidbody.AddForceAtPosition(-transform.forward * 2, transform.position + (transform.up * 5), ForceMode.Impulse); > else > deadModelRigidbody.AddForceAtPosition(transform.forward * 2, transform.position + (transform.up * 2), ForceMode.Impulse);
 * __**Rotating a game object (JavaScript)**__ var deadModel = Instantiate(deadModelPrefab, transform.position, transform.rotation);

Scripting Overview