-
Search Results
-
Hi guys im new with unity and of course new with Rain. I follow all the tuts from the utube channel and all works good. Now im working with Meca, and all works good too.
So.. my AI character, chases me, stop when he reachs my position and do the animation of the hit…. So… i get the point of all the tuts but:
Now i want to control the death of my AI character, but i dont know how. I mean
I have in the pistol a script which shoots, and if the AI character is in that layer/tag do all the things. I have a simple script to receive the damage with the function TakeDamage like this:
`public class HealthEnemy : MonoBehaviour {
public float hitPoints=100f;
public float currentHitPoints;
void Start () {currentHitPoints = hitPoints;
}
void Update () {
}
public void TakeDamage(float amt)
{
currentHitPoints -= amt;
}}`
Well… i have this script on the root of my AI character, to deal with the death. And now i want to use that variable currentHitPoints on Rain…. So if currentHitPoints>0 make all the stuff i put on the behaviour tree , and if currentHitPoints<=0 deal with the death of AI character and get destroyed after the animation…
So, my question is, how i get that var (currentHitPoints) value on Rain? I tried making it public, and using a constraint with the condition currentHitPoints>0 but it didnt work.
Anyone can help me? Or know any tut about this?
PS: I think i could deal with the dead making a script who destroy the AI gameobject, and making it through scripting on the animador (like… animador.setBool(“Death”,true);) But i think its interesting to me understand how it works, to make new conditions like a animation when the AI received the hit… or so..
- This topic was modified 5 months ago by ZackHanzo.
Hey everyone! I’m going to do my best to explain the situation. My brains are fried at the moment, so I decided to turn to the community for help.
So for the past couple days, I’ve been trying to create a simple Zombie AI. To wander (at the moment, follow a set path), Detect the player, and when the zombie is within a specific distance attack. All is working well, I have the zombie detect the player, and run towards him, and once he’s within a certain distance, do an attack animation. And if the player leaves the First Detector range, he returns to wandering/path. The only issue I am having, is that the Sensor for detection, (eyes) has a limited FOV. So the player can run around behind the zombie, without attracting aggro. So, naturally I thought, I’d just make another sensor with basically the same properties as the “eyes” sensor. and name it something like Sense. Here’s a screenshot of my sensors ATM.
The Blue sensor are the “eyes” the Red is the “sense” and the smaller white one is the “touch” for the attack anim.
I can aggro with the eyes sensor, but not the Sense sensor.
The current setup I have, the two aggro sensors (eyes, sense) both have the same FormVariable, because I figured, if you could trigger one, you could trigger both. I don’t know how to set up/use Audio sensors, I figured visual would work. The Eyes Sensor has a horizontal angle of 136 with LOS required, while the Sense Sensor has a 360 with no LOS required. I’ve been trying to get this to work for a while. Now here’s the strange part. If I Cut/remove the “eyes” Detector from the BT, I can aggro with the Sense Sensor.
Should I just learn how to set up audio sensors? or is it possible to get this working with multiple visual sensors.
If it’s needed, here’s my BT XML<behaviortree version="1.1" repeatuntil="" name="Zombie1"><parallel tiebreaker="fail" succeed="all" repeatuntil="" name="parallel" fail="any"><detect sensor=""close"" repeatuntil="running" name="ATKRange" entityobjectvariable="varTouch" aspectvariable="" aspectobjectvariable="" aspect=""aSurvivor"" /><detect sensor=""sense"" repeatuntil="running" name="Sense" entityobjectvariable="varSeen" aspectvariable="" aspectobjectvariable="" aspect=""aSurvivor"" /><detect sensor=""eyes"" repeatuntil="running" name="See" entityobjectvariable="varSeen" aspectvariable="" aspectobjectvariable="" aspect=""aSurvivor"" /><selector usepriorities="False" repeatuntil="" name="Is Survivor seen?"><constraint repeatuntil="" priority="" name="No" constraint="varSeen == null"><parallel tiebreaker="fail" succeed="all" repeatuntil="" name="parallel" fail="any"><mecparam valueexpression="0.0" repeatuntil="" parametertype="float" parametername="Atk" name="ATK = 0" damptime="0" /><waypointpatrol waypointsetvariable="PatrolRoute" waypointactiontype="patrol" traversetype="loop" traverseorder="forward" repeatuntil="" pathtargetvariable="" name="Walk" movetargetvariable="nextWP"><move turnspeed="" repeatuntil="" name="move to WP" movetarget="nextWP" movespeed="1" facetarget="" closeenoughdistance="" closeenoughangle="" /></waypointpatrol><animate repeatuntil="" name="Walk" animationstate="Walk" /></parallel></constraint><constraint repeatuntil="" priority="" name="Yes" constraint="varSeen != null"><selector usepriorities="False" repeatuntil="running" name="Is Survivor within attack range?"><constraint repeatuntil="" priority="" name="Yes" constraint="varTouch != null"><move turnspeed="" repeatuntil="" name="Face" movetarget="" movespeed="" facetarget="varSurvivor" closeenoughdistance="" closeenoughangle="" /><animate repeatuntil="" name="Attack" animationstate="Atk" /></constraint><constraint repeatuntil="" priority="" name="No" constraint="varTouch == null"><parallel tiebreaker="fail" succeed="all" repeatuntil="" name="parallel" fail="any"><animate repeatuntil="" name="Run" animationstate="Run" /><mecparam valueexpression="0.0" repeatuntil="" parametertype="float" parametername="Atk" name="Atk = 0" damptime="0" /><move turnspeed="" repeatuntil="" name="Move to Survivor" movetarget="varSeen" movespeed="4" facetarget="" closeenoughdistance="" closeenoughangle="" /></parallel></constraint></selector></constraint></selector></parallel></behaviortree>
- This topic was modified 5 months, 2 weeks ago by OMGItzGnaR.
- This topic was modified 5 months, 2 weeks ago by OMGItzGnaR.