Graphics Reference
In-Depth Information
When useForceVectorDirection is set to true, theDir is set to the Vector from the
variable forceVector, which should be set in the Unity editor Inspector window on the
gameObject:
if( useForceVectorDirection )
theDir = forceVector;
The ownerNum variable was mentioned earlier in this section, where it is set by the
SetOwner() function. When the call to the currently selected weapon's Fire() function
goes out, it takes a Vector3 and the owner ID:
// fire the projectile
TEMPWeapon.Fire( theDir, ownerNum );
}
}
6.1.2 BaseWeaponScript.cs
Here is the BaseWeaponController.cs script in its completed form:
using UnityEngine;
using System.Collections;
public class BaseWeaponScript : MonoBehavior
{
[System.NonSerialized]
public bool canFire;
public int ammo= 100;
public int maxAmmo= 100;
public bool isInfiniteAmmo;
public GameObject projectileGO;
public Collider parentCollider;
private Vector3 fireVector;
[System.NonSerialized]
public Transform myTransform;
private int myLayer;
public Vector3 spawnPosOffset;
public float forwardOffset= 1.5f;
public float reloadTime= 0.2f;
public float projectileSpeed= 10f;
public bool inheritVelocity;
Search WWH ::




Custom Search