RAIN Tutorial – Sentio Characters and UFPS

NOTE – There are issues with UFPS 1.5.1 Integration.  So this works with the prior version.  SCROLL TO BOTTOM FOR UFPS 1.5.1 SOLUTION

The team over at RivalTheory provided edits for the Sentio Characters in order to allow them to work well with UFPS.  This video covers those steps and process.  All scripts edits were created by RivalTheory.

RivalTheory Forum Edits by RivalTheory team
http://rivaltheory.com/forums/topic/darkness-warlord-ufps/page/2/#post-37886

UFPS

RivalTheory Products

For Respawning – I put this script on the base (Parent) of the UFPS Player

using UnityEngine;
using System.Collections.Generic;
using RAIN.Core;
using RAIN.Serialization;
using RAIN.Entities;
using RAIN.Entities.Aspects;
using Sentio.CreaturePack;

public class ResetMe : MonoBehaviour {

	private vp_PlayerEventHandler m_Player = null;	// should never be referenced directly
	public vp_PlayerEventHandler Player	// lazy initialization of the event handler field
	{
		get
		{
			if (m_Player == null)
				m_Player = transform.GetComponent<vp_PlayerEventHandler>();
			return m_Player;
		}
	}

	void LateUpdate () 
	{
		if(Player.isActiveAndEnabled==true)
			SetAliveAspects(true);
	}
	public void SetAliveAspects(bool aIsAlive)
	{
		EntityRig[] tEntityRigs = GetComponentsInChildren<EntityRig>();
		foreach (EntityRig tRig in tEntityRigs)
		{
			if (tRig == null)
				continue;
			
			IList<RAINAspect> tAspects = tRig.Entity.Aspects;
			foreach (CreatureAspect tCreatureAspect in tAspects)
			{
				tCreatureAspect.IsAlive = aIsAlive;
			}
		}
	}
}

Edits per Prime at RivalTheory. The below information is also on their forum post linked above.

Make this change to DamageOnCollision.cs:


//            DamageMessage tDamage = new DamageMessage() { damageGiver = tGiver, damageAmount = DamageAmount };
//            aOtherCollider.gameObject.SendMessageUpwards("Damage", tDamage, SendMessageOptions.DontRequireReceiver);

            vp_DamageInfo tDamage = new vp_DamageInfo(DamageAmount, tGiver.transform, tGiver.transform, vp_DamageInfo.DamageType.Impact);
            aOtherCollider.gameObject.SendMessageUpwards("Damage", tDamage, SendMessageOptions.DontRequireReceiver);

Add this to DamageMessageReceiver.cs

public virtual void Damage(vp_DamageInfo aDamageMessage)
        {
            CurrentDamage += aDamageMessage.Damage;
        }

Add this to AIDamageReceiver.cs

public override void Damage(vp_DamageInfo aDamageMessage)
        {
            base.Damage(aDamageMessage);
            if ((HealthElement != null) && (aDamageMessage.Damage > 0))
            {
                if ((aDamageMessage.OriginalSource != null) && (aDamageMessage.OriginalSource.IsChildOf(HealthElement.AI.Body.transform)))
                    return;

                object tEnemy = HealthElement.AI.WorkingMemory.GetItem("currentEnemy");
                if (tEnemy == null)
                {

                    HealthElement.AI.WorkingMemory.SetItem("currentEnemy", FindAliveCreatureAspect(aDamageMessage.OriginalSource.gameObject));
                }
            }
        }

HeaderWP

FOR UFPS 1.5.1 – Do not make any changes to the Sentio Scripts.  Add this to the base (Parent) of your Sentio Character.

using UnityEngine;
using System.Collections;
using Sentio.DarknessWarlord;
using Sentio.CreaturePack;
//Thanks to Johannes Holweg from Germany for creating this script to be used as an interface with UFPS

namespace red{//Create any namespace you want.  Just for organizing
    public class UFPS_Rain_Bridge_SENTIO : MonoBehaviour {

        public float ufpsDamageMultiplier = 10.0f;
        private AIDamageReceiver aiDmgRcvr;
        
        // Use this for initialization
        void Start () {
            aiDmgRcvr = this.gameObject.GetComponentInParent<AIDamageReceiver>();
        }

        public virtual void Damage(float damage)
        {
            if (aiDmgRcvr != null)
            {
                aiDmgRcvr.CurrentDamage += damage * ufpsDamageMultiplier;
            }
        }
    }
}

Advertisements

5 thoughts on “RAIN Tutorial – Sentio Characters and UFPS”

  1. “Do not make any changes to the Sentio Scripts. Add this to the base of your Sentio Character.”

    I have 1.5.1 so I need to do this. But I don’t see a base folder for the Sentio Character.

    Like

    1. When I say Base, I mean the highest level of the UFPS player. So, if you drag your UFPS Player prefab into the scene, the player will have multiple child objects. The Base, would be the highest level parent.

      Like

  2. Hi there, i love your videos and so far all good. But on this tutorial o have a problem because i got the last version of UFPS and RAIN and thoses files you use in the video are not in the assets anymore. Can you give a update on what files to change now?

    Like

    1. I have no idea when that would happen, sorry. You should be able to update the scripts if you follow the logic. I just don’t think I will get to it, especially with RAIN going away sometime soon.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s