Wednesday, June 29, 2011

Unity FPS Shooter Game tutorial


First we create an empty object called Launcher and then make it as a child of Main Camera and attach the script below to it  and give launcher an object that will be a  launched missile which has  to be a rigid body.
========================================================================

Here 
is  
the  
full  
code
  to
  MissileLauncher.js:
var projectile : Rigidbody;
var speed = 20;
function Update()
{
 if( Input.GetButtonDown( "Fire1" ) )
  {
  var instantiatedProjectile : Rigidbody = Instantiate(
   projectile, transform.position, transform.rotation );
  instantiatedProjectile.velocity =
   transform.TransformDirection( Vector3( 0, 0, speed ) );
  Physics.IgnoreCollision( instantiatedProjectile. collider,
   transform.root.collider );
  }
}


No comments:

Post a Comment