forzabo
Member
Since updating to the latest version UFPS this afternoon (I purchased it only a few weeks ago, so I think this was a minor update), when I shoot at a game object with a simple target script attached, I get this error -- whether I use a projectile or the raycast/ hitscan method:
FWIW, here's my very simple target script:
I am stumped! Something is obviously not configured ... but what?
any ideas on how to chase this down will be most appreciated.
Code:
NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateCharacterController.Events.EventHandler.ExecuteEvent[T1,T2,T3,T4,T5,T6] (System.Object obj, System.String eventName, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) (at Assets/Opsive/UltimateCharacterController/Scripts/Events/EventHandler.cs:605)
Opsive.UltimateCharacterController.Objects.Destructible.OnCollision (System.Nullable`1[T] hit) (at Assets/Opsive/UltimateCharacterController/Scripts/Objects/Destructible.cs:217)
Opsive.UltimateCharacterController.Objects.Projectile.OnCollision (System.Nullable`1[T] hit) (at Assets/Opsive/UltimateCharacterController/Scripts/Objects/Projectile.cs:64)
Opsive.UltimateCharacterController.Objects.TrajectoryObject.Move (UnityEngine.Vector3& position, UnityEngine.Quaternion rotation) (at Assets/Opsive/UltimateCharacterController/Scripts/Objects/TrajectoryObject.cs:542)
Opsive.UltimateCharacterController.Objects.TrajectoryObject.FixedUpdate () (at Assets/Opsive/UltimateCharacterController/Scripts/Objects/TrajectoryObject.cs:465)
FWIW, here's my very simple target script:
C#:
using UnityEngine;
using Opsive.UltimateCharacterController.Events;
public class Target : MonoBehaviour
{
[SerializeField] private GameObject particles;
/// <summary>
/// Initialize the default values.
/// </summary>
public void Awake()
{
EventHandler.RegisterEvent<float, Vector3, Vector3, GameObject, Collider>(gameObject, "OnObjectImpact", OnImpact);
}
/// <summary>
/// The object has been impacted with another object.
/// </summary>
/// <param name="amount">The amount of damage taken.</param>
/// <param name="position">The position of the damage.</param>
/// <param name="forceDirection">The direction that the object took damage from.</param>
/// <param name="attacker">The GameObject that did the damage.</param>
/// <param name="hitCollider">The Collider that was hit.</param>
private void OnImpact(float amount, Vector3 position, Vector3 forceDirection, GameObject attacker, Collider hitCollider)
{
Debug.Log(name + " impacted by " + attacker + " on collider " + hitCollider + ".");
Instantiate<GameObject>(particles,transform.position,Quaternion.identity);
Destroy(gameObject);
}
/// <summary>
/// The GameObject has been destroyed.
/// </summary>
public void OnDestroy()
{
EventHandler.UnregisterEvent<float, Vector3, Vector3, GameObject, Collider>(gameObject, "OnObjectImpact", OnImpact);
}
}
I am stumped! Something is obviously not configured ... but what?
any ideas on how to chase this down will be most appreciated.