Behavior Designer with Ultimate Inventory System

Vahalla

Member
I have been trying to get the melee working like the agent nolan in the demo, i have the enemy set up like agent nolan, problem is when enemy 1 dies, and respawns, he just runs around player , when i stop start the game he has his katana and will attack player 1, its as if the load out from the uis is not replacing the weapon , like agent nolan in the demo any help or direction would be appriceated
 
What does your tree look like? What task is active when the agent isn't doing what you'd expect?
 
the tree is a copy of the melee that was in the demo, the agent is running around the player and not attacking or have the katana equipped
 
when i watch the demo, i can kill agent nolan, and when he respawns, the weapon is equipped, i think it is because you have no uis in the demo, and it is ucc inventory , the inventory loadout , i will be trying this today to just use the ucc to make sure this is or not it
 
i am starting to see what is going on and this is a pretty cool thing, i just can not figure out how to get the enemy to equip a weapon in the inventory that is on them i found the task for it, applied the gameoject in the field, the item slot ect, nothing, what am i missing on setting up the enemy to equip a weapon after death and respawn?
 
Are you using version 3 of the character controller? We don't have a melee specific demo scene. I am unable to support version 2 of the character controller anymore.
 
Are you using version 3 of the character controller? We don't have a melee specific demo scene. I am unable to support version 2 of the character controller anymore.
justin i figured out what was going on, and no , i am using legacy for the uis, which i know was said not to be supported, but where on that melee behavior tree is the attack distance , i have it to where enemy cast a fire ball but only if we are face to face , what task was used to determine where the enemy is to attack from, after this answer i think i will be golden, thanks
 
ps i am asking all this to better understand what is going on, with behavior designer , so then i can start to create my own trees
 
ok i found the variables, and i have it to where the enemy attacks from futher away with a fireball, now how do i get them to stay further away and still attack?
 
using UnityEngine;
using Opsive.ThirdPersonController;


{
[TaskCategory("Custom/Attacking")]
[TaskDescription("Keep the target GameObject at a certain distance to perform an attack.")]
public class KeepDistanceAttack : Action
{
[Tooltip("The target GameObject to attack.")]
public SharedGameObject targetGameObject;

[Tooltip("The desired attack distance.")]
public SharedFloat attackDistance;

private ThirdPersonController.InputHandler m_InputHandler;

public override void OnStart()
{
m_InputHandler = GetComponent<ThirdPersonController.InputHandler>();
}

public override TaskStatus OnUpdate()
{
if (targetGameObject == null || targetGameObject.Value == null)
{
return TaskStatus.Failure;
}

float distanceToTarget = Vector3.Distance(transform.position, targetGameObject.Value.transform.position);

if (distanceToTarget > attackDistance.Value)
{
// Move towards the target to maintain distance
Vector3 moveDirection = (targetGameObject.Value.transform.position - transform.position).normalized;
m_InputHandler.SetInputVector(moveDirection);
}
else
{
// Perform the attack action
// Replace this with the actual attack action you want to trigger
// For example: m_InputHandler.Attack();
}

return TaskStatus.Running;
}

public override void OnEnd()
{
// Stop any movement
m_InputHandler.SetInputVector(Vector3.zero);
}

public override void OnReset()
{
targetGameObject = null;
attackDistance = 0f;
}
}
}
Will this work correctly as a task for then enemy to be with in a certain range to attack
Like a ranged attack for ai?
 
Sorry I forgot some things,
using UnityEngine;
using Opsive.ThirdPersonController;
using BehaviorDesigner.Runtime;
using BehaviorDesigner.Runtime.Tasks;


{
[TaskCategory("Custom/Attacking")]
[TaskDescription("Keep the target GameObject at a certain distance to perform an attack.")]
public class KeepDistanceAttack : Action
{
[Tooltip("The target GameObject to attack.")]
public SharedGameObject targetGameObject;

[Tooltip("The desired attack distance.")]
public SharedFloat attackDistance;

private ThirdPersonController.InputHandler m_InputHandler;
private bool isAttacking;

public override void OnStart()
{
m_InputHandler = GetComponent<ThirdPersonController.InputHandler>();
isAttacking = false;
}

public override TaskStatus OnUpdate()
{
if (targetGameObject == null || targetGameObject.Value == null)
{
return TaskStatus.Failure;
}

float distanceToTarget = Vector3.Distance(transform.position, targetGameObject.Value.transform.position);

if (distanceToTarget > attackDistance.Value)
{
// Move towards the target to maintain distance
Vector3 moveDirection = (targetGameObject.Value.transform.position - transform.position).normalized;
m_InputHandler.SetInputVector(moveDirection);
isAttacking = false;
}
else if (!isAttacking)
{
// Start the attack action
isAttacking = true;
return TaskStatus.Running;
}

return TaskStatus.Success;
}

public override void OnEnd()
{
// Stop any movement
m_InputHandler.SetInputVector(Vector3.zero);
isAttacking = false;
}

public override void OnReset()
{
targetGameObject = null;
attackDistance = 0f;
isAttacking = false;
}
}
}
 
I haven't looked at the version 2 setup in awhile so I don't remember what it looks like. There is a YouTube video that shows how the tree works so you could take a look at that.
 
Yeah I did and the docs, there is nothing on a way to stop the enemy target from coming in , even in the shooter demo agent Nolan runs up extremely close thank you tho
 
Top