This topic contains 36 replies, has 7 voices, and was last updated by  prime 2 years, 2 months ago.

Viewing 15 posts - 1 through 15 (of 37 total)
  • Author
    Posts
  • #5691

    markfrancombe
    Participant

    Hi, I brought this over fromm post at…
    http://rivaltheory.com/forums/topic/rain-without-coding/

    It was probably the wrong place, and NOW I have a more specific question. (Probably better to break down my huge rambling monologue into short concise issues… failing so far, sorry..)

    So I need to have a wandering NPC detect my Player Char, and IMMEDIATELY quit its wandering and go/run home, cos Im a badMF.

    Im not understanding how to set up a detect node. I would have expected it to work better as a branching node, so that if NON detection happened we go one way, but if detection happened it would go another way.

    But RAIN seems to want to do everything by whether a collection if things is true or not.

    So I put my detect node under a parallel that also contains the “things I want him to do” if the detection happens. (is this right?)

    The OTHER option (what happens BEFORE detection) is all under a random node, just because its a few random things that the NPC does untill he detects me.

    But the actual CHOICE node should be what? Ive tried Sequencer, and Selector.. I think Sequencer is wrong (as shown in the image) as it will go thru the first choice before checking the detect right? But I cant get Selector to work either.
    I need the detect to work IMMEDIATLY the NPC spots me, whatever he is doing at the time, then switch to a series of actions, that will not loop out of. (I actually need him to enter a house, and stop. Waiting for me to be out of range again, before tentatively emerging into the street again.
    I think that the detect IS working, because some or other random settings (that didnt work) the npc DID spot me and walk, but not correctly.

    Heres what I am trying, please tell me what IM doing wrong!

    #5695

    prime
    Keymaster

    This was my response to your other post:


    Easy enough. Put a parallel as your top node. Add a Detect node that repeats forever and looks for the aspect you placed on the player. Use the Form Variable to hold the result (let’s call the variable player). Next add a Selector. In that Selector add two Constraints. The first Constraint will evaluate “player == null”. Place your normal path behavior in that one. The second Constraint will evaluate “player != null”. Place your run home behavior in that one. Run home can be as simple as a Move with a Vector target.


    So, if I’m reading your BT correctly, your random node would go within the first constraint. Move the detect out of your bottom parallel and use it per my suggestion. Then your second constraint would contain a parallel with a move and an animate.

    Also, you should probably set your move nodes to repeat forever in your patrol branches. I’m assuming the timer returns true to kick you out of that branch.

    • This reply was modified 2 years, 4 months ago by  prime.
    • This reply was modified 2 years, 4 months ago by  prime.
    • This reply was modified 2 years, 4 months ago by  prime.
    #5701

    markfrancombe
    Participant

    Thanks for the reply Prime.

    Still not working Im afraid, but I certainly GET what you meant here.
    IM not too sure how to set all the repeats on all the nodes (apart from the ones you told me). But more worrying, Im not sure that the detect is working at all. When I enter the area depicted by the Visual Sensors gizmo, nothing happens at all.
    So firstly, is THIS what you meant?

    The detect is set up thus:

    The first constraint is:

    The second is the same only with playerVar != Null (Should I have “” around this, thus”playerVar != Null”???)

    And finally, the Entity on my Player CHaracter is set up thus:

    Anything here wrong?

    Sorry if I seem completely stupid, I tell ya, I feel it right now… But am REALLY looking forward to gettin my head around this, its going to be awesome I can feel it!!

    Mark

    #5709

    markfrancombe
    Participant

    Im 90% sure that the problem is in the setting up of the sensor and the entity.
    I have changed one thing above. The form variable on the detect node is changed to SimplePlayer just because THAT is the name in the Entity on my Player character. I dont know if this is correct (I just tried it cos they were both called Form). It has an Visual Aspect called Me.
    The constraints also have new Var names SimplePlayer == Null. etc.. Again.. just.. er.. because.. trying a few things.

    #5711

    markfrancombe
    Participant

    ONE STEPP CLOSER STILL:

    I had not noticed the hint on the Detect Node. …Store the result in an AI Memory Variable.

    So I go to the memory tab of my AI and add a variable name. (What type? I tried a few, string, bool etc)
    This variable name is the same thing I put in the constraints AND that is in the detect node Form Variable slot(Not sure WHY Form , but its what you said.. can you elucidate?).

    Still not working, but getting closer every minute I think…?

    M

    • This reply was modified 2 years, 4 months ago by  markfrancombe.
    • This reply was modified 2 years, 4 months ago by  markfrancombe.
    #5715

    Aaron Mueller
    Participant

    @markfrancombe,
    I believe @prime said to use a Form Variable as it looks like you did in the screen shots.

    To the best of my knowledge, if you use a Form Variable it is stored as a GameObject in the WorkingMemory. While your NPC is running in the Unity Editor, click on the AI child gameobject so you can see the AIrig and the RAIN components. Click on the Memory icon (the leftmost) and look at the values that are in the memory.

    NOTE: You may need to click off the Memory icon and click on a different one and then back again to “refresh” the contents of the memory. @prime mentioned in a reply to me that there are some issues with refreshing the contents of the AIrig in the Unity Editor and that’s the best way I have found to force it to refresh.

    From my recollection, the variable shows a little icon next to the detected object which I believe represents the gameobject (a.k.a. form) that the Aspect is attached to.

    Hope that helps. Good luck.

    #5716

    markfrancombe
    Participant

    That helped ALOT!
    It helped by showing me that I DIDNT have to SET a variable in the memory tab, its done automatically!
    So I can see BOTH my moveTarget variable and my detect variable being created. However the detect variable, is staying at NULL. So my detect is not working, as I suspected. I can see that the Behavior tree IS reading the detect node (its going orange) but nothing is changing when my Player intersects the AIs Sight Sensors area.

    I wonder why?

    #5724

    prime
    Keymaster

    Where is the FPSCamera you are using for a mount point? And do you have RequireLineOfSight checked in your Sensor? (Thanks for all the various screenshots. It helps.)

    #5747

    markfrancombe
    Participant

    FPSCamera was just a point on my character rig, kinda head height… And yes I do have require line of sight checked. This is because its for a part of my game where you must creep up on some AI talking and overhear their conversation, if they see you they run off.

    Mark

    #5748

    prime
    Keymaster

    Make sure that, if the mount point is inside the colliders on the player, you set up the line of sight mask so that it ignores those colliders.

    #5754

    markfrancombe
    Participant

    That might be the thing… testing now, its looking good!

    Mark

    #5769

    markfrancombe
    Participant

    Result, not without speedbumps. Now I have got the detct working, yes it WAS the collidor getting in the way. I parented a empty GO to my Player now.

    But now.. when I enter the area defined by the AIs sensor, it STILL doesn’t switch over to the other constraint.

    OR.. wait… it does now.. and he is moving towards his home (see original requirements)but not playing animation, and another thing.. he only does it AS LONG AS I am within his Sensor area. I want the detect (I think) to cause a switch in behaviour, so he runs home whatever… Then once he has disappeared inside a house (another upcoming requirement, have the AI disappear… Hmmm) he should wait a bit THEN if IM not within his Sensor area, come out and start his wandering.

    So current issue is:

    How can I get the Sensor trigger to be persistent, and play a behavior to end, rather than only happening when Im close enough?

    Mark

    #5770

    prime
    Keymaster

    Try putting your detect in a sequencer and set a flag. Like:
    SEQ
    — Detect (player)
    — Expression (foundplayer = true)

    Then switch your behavior not on player != null but on foundplayer == true

    #5780

    markfrancombe
    Participant

    Lost…

    Are you saying to completely rearrange my tree now? Are we replacing my CONs with a SEQ now, so the detect moves the behavior from the first path (the wandering RAN loops) to a second path (that is currently in my second CON?

    OH dammit… heres another Screeny…!

    I do GET what you are suggesting, but Im overwhelmed by the amount of options it soon adds up to with every node having repeat settings and fail/succeed settings… Thanks you so much for hand-holding me through this… Im sure Ill get it in the end! (???)

    Mark

    #5781

    Aaron Mueller
    Participant

    @markfrancombe,
    Ok, now that I see your tree, unless there are some other issues, just take that lonely detect node at the bottom and wrap it in a Sequencer like @prime suggests. Then, in your two CONSTRAINT nodes, just replace your original variable with the result of the foundplayer.

    So, in the “Run home in fear” branch, your constraint would be “foundplayer == true”. Then only when that is true will he execute this.

    Not sure about the proper way to set the repeat until. In my own tree, the whole thing keeps restarting so that I was seeing some strange behavior (or at least, unexpected based on my limited understanding).

Viewing 15 posts - 1 through 15 (of 37 total)

You must be logged in to reply to this topic.