Updating Tactical AI to the new UFPS2

IAMOLD

New member
Error show upon importing Tactical AI into the project:

Tactical AI\Csharp\Damage Scripts\HitBox.cs(33,13): error CS0234: The type or namespace name 'ImpactEvent' does not exist in the namespace 'Opsive.UltimateCharacterController' (are you missing an assembly reference?)

Sorry if the problem is easy to fix, i don't know anything about coding. Here's the error code:

#if FIRST_PERSON_CONTROLLER && ULTIMATE_CHARACTER_CONTROLLER_SHOOTER
Opsive.UltimateCharacterController.Events.EventHandler.RegisterEvent<float, Vector3, Vector3, GameObject, object, Collider>(gameObject, "OnObjectImpact", OnImpact);
#endif
 
Last edited:
Error show upon importing Tactical AI into the project:

Tactical AI\Csharp\Damage Scripts\HitBox.cs(33,13): error CS0234: The type or namespace name 'ImpactEvent' does not exist in the namespace 'Opsive.UltimateCharacterController' (are you missing an assembly reference?)

Sorry if the problem is easy to fix, i don't know anything about coding. Here's the error code:

#if FIRST_PERSON_CONTROLLER && ULTIMATE_CHARACTER_CONTROLLER_SHOOTER
Opsive.UltimateCharacterController.Events.EventHandler.RegisterEvent<float, Vector3, Vector3, GameObject, object, Collider>(gameObject, "OnObjectImpact", OnImpact);
#endif

so i spend some time studying the weapon shooter script and found that they have a similar "#if FIRST_PERSON_CONTROLLER .." so i change the error line with that line and no more error:
C#:
#if FIRST_PERSON_CONTROLLER && FIRST_PERSON_CONTROLLER_SHOOTER
            Opsive.UltimateCharacterController.Events.EventHandler.RegisterEvent<float, Vector3, Vector3, GameObject, Collider>(gameObject, "OnObjectImpact", OnImpact, damageAmount);
#endif
        }

        //UFPS 2 SUPPORT
        void OnDisable()
        {
#if FIRST_PERSON_CONTROLLER && FIRST_PERSON_CONTROLLER_SHOOTER
            Opsive.UltimateCharacterController.Events.EventHandler.UnregisterEvent<float, Vector3, Vector3, GameObject, Collider>(gameObject, "OnObjectImpact", OnImpact, damageAmount);
#endif
        }

        void OnImpact(float amount, Vector3 position, Vector3 direction, GameObject attacker, Collider hitCollider)
        {
            ApplyDamage(amount);
            StartCoroutine(AddForceVector(direction));
        }

Even though the ai detects the impact of the gun hitscan bullet (judging by the bullet hole (surface impact)), it deals no damage. I think it would have something to do with the "applydamage.." line but i don't how to read code im stuck :V

One way around this is using the "on hitscan impact event" in the shootable weapon script of ufps, and apply direct damage to the health script of the AI. But then you can't use body damage multiplier (like headshot). And worst you have to apply this method to every single AI you have on the scene for it deal damage ( and every gun)

really appreciate if anyone can help figure this out, i can give you the code since i just realize that Tactical AI is no longer in support of the old dev :V
Or just show me the minimum requirement to use the damage handler of UFPS so the AI can just control a UFPS character
 
Last edited:
I haven't used the Tactical AI asset before so I'm not really able to help but calling OnObjectImpact is correct, similar to:

 
So i found out this old video of the dev that shows how to use both the UFPS 1 and Tactical AI together (the original video on youtube is gone). And from the vid, UFPS deal damage to AI by sending out "damage(float)" via unity message. I just got the new UFPS2 recently and can't read code so i guess the new system use different ways or different "damage" message name to send to colliders. So is there a way to change how the damage is dealt, aside from the "on hitscan impact event slot"
 
To whom still looking for answer i post the fix in the attachment file
 

Attachments

  • HitBox.cs
    4.1 KB · Views: 1
Top