News Forums Search Search Results for '2D'

Viewing 15 results - 1 through 15 (of 58 total)
  • Author
    Search Results
  • #38440

    Sigil
    Keymaster

    Hmmmm, well I’ve thought through a few scenarios with this and I can’t come up with something that would work quite the way you need. One possibility, and I’ve done this before, is to use a 1D blend tree to blend between two other blend trees. I’m not positive this will give you good looking animations though, and may limit your turning a bit:

    1D Blend Tree using RotationY
    2D blend tree using VelocityX and VelocityZ (forward and strafing)
    1D blend tree using RotationY (turn left/right)

    I feel like a better solution for this would be to use two separate trees (likely what you already have), allowing you to use a transition between the turn left/right and movement. If you defined a set of turning animations I think you’d be able to blend almost any turn and then transition to walking or running, giving you a lot of control.

    Sorry, I realize this isn’t quite what you are looking for, but perhaps it gives you some ideas.


    christougher
    Participant

    I figured I would pitch this here. I’m trying to figure out how to have RAIN manipulate three mecanim float variables (Xvelocity, Zvelocity, and Yrotation) at the same time. All of these variables are set up with coordinate values of -1 (strafe left, back and turn left), 0 (idle) and +1 (strafe right, move forward and turn right). I get sub-par results by switching between two blend trees in mecanim. As 2d blend trees only use two variables the input from Rain’s MecanimMotor is partly wasted. The ‘direct’ type of blend tree can have multiple variables but appears to phase out all input at zero and below. Anyone know of a way that I could have all three of these mecanim variables receive input (and thus animate) from Rain simultaneously?


    Technikneus
    Participant

    Hello peeps,

    My behavior tree uses the premade move action. I’m trying to change the MoveSpeed variable through my script, but I can’t seem to get it working.

    using UnityEngine;
    using System.Collections;
    using RAIN.Core;
    public class Ganai : MonoBehaviour {
    	public Camera playerCamera;
    	public LayerMask ignoredLayers;
    	private AIRig tRig;
            public GUISkin customSkin;
    	public Texture2D eTex;
    	private int eTexPosX = 0;
    	private int eTexPosY = 0;
    	private int eTexSize = 100;
    	public float beginCooldownE;
    	private float currentCooldownE;
    	private float realTimeCooldownE;
    	void Start() {
    		currentCooldownE = beginCooldownE;
    	}
    	void Update() {
    		if(Input.GetKeyDown(KeyCode.E)) {
    			if(realTimeCooldownE <= 0) {
    				Ray ray = playerCamera.ScreenPointToRay(Input.mousePosition);
    				RaycastHit hit;
    				if(Physics.Raycast(ray, out hit, 100, ignoredLayers)) {
    					tRig = gameObject.GetComponentInChildren<AIRig>();
    					float movSpeed = tRig.AI.WorkingMemory.GetItem<float>("moveSpeed");
    					Debug.Log(movSpeed);
    					//tRig.AI.WorkingMemory.SetItem<float>("moveSpeed", movSpeed);
    					//MovePosition movePosi = transform.GetComponentInParent<MovePosition>();
    					//movePosi.movePoint.position = hit.point;
    				}
    				realTimeCooldownE = currentCooldownE;
    			}
    		}
    		realTimeCooldownE -= Time.deltaTime;
    		if(realTimeCooldownE < 0) {
    			realTimeCooldownE = 0;
    		}
    	}
    	void OnGUI() {
    		GUI.skin = customSkin;
    		GUI.depth = 3;
    		if(realTimeCooldownE >= 1) {
    			GUI.Label(new Rect(eTexPosX, eTexPosY, eTexSize, eTexSize), realTimeCooldownE.ToString("f0"));
    		} else if(realTimeCooldownE > 0 && realTimeCooldownE < 1) {
    			GUI.Label(new Rect(eTexPosX, eTexPosY, eTexSize, eTexSize), realTimeCooldownE.ToString("f1"));
    		}
    	}
    }

    Thanks in advance!

    • This topic was modified 3 weeks, 4 days ago by  Technikneus. Reason: Forget the GUISkin variable
    #37987

    micuccio
    Participant

    Hi there!
    I would like to ask some clarifications concerning the Navmesh.
    Here is what I was thinking to do (based on the new Rain Update) :
    a)split my terrain in small “grids” and name it consistently (eg : Tile_00, Tile_01, Tile_34 according with a 2d Coordinate system)
    b)Generate on each of them the Navmesh (with the corresponding naming es :Nav_00, Nav_01, Nav_34 and so on)
    and attaching it to the terrain splitted “tiles” prefabs
    c)As soon the navmesh contained in the “grid” is interested by a change (eg a cube appear in the grid or another GameObject is there) the Navmesh should regenerate.

    In this way, as much I am thinking, the navmesh will take in account of :
    1)new appearing static objects (rocks, trees, stuff)
    2)potentially extended to AIs (this will be for sure more costly, because will require a navmesh update every frame, BUT if the grid is small, even the navmesh area to update will be small, right?)

    Now, I did not test this still but I am planning to do. My question is :
    Is it feasible? I mean is it possible to tell the Navmesh to update in runtime IF another GameObject is within is area/space?

    Thanks in advance for the answer,

    #37616

    Olin
    Participant

    Hi Prime,

    The AI is working now with Set Mecanim Parameters and MecanimMotor ! Thanks for your tips as I am getting much more comfortable with RAIN comparing to when I have started last week and so this topic should be closed shortly :)

    My last questions.

    (1)
    I have not added any parameters to the MecanimMotor itself as I’m not sure how would I use them with triggers. I imagine your pt.2 applies to running where additional mecanim parameter is set. A detailed example of how to “activate” or “use” triggers for running would be appreciated. FYI I am using one mecanim state with 2D blend tree to handle walking in all directions and another state to handle running forward. That’s it.

    (2)
    I am experimenting with damp time for mecanim parameters now but without much success. For [MECANIM PARM] Walk=1 and Damp = 0.05 I never get to the full length animation. The forward root motion is getting to full speed but the animation never gets to full length walking movement. Similiar for stopping. When I set Walk = 0 with Damp = 0.05 my AI is wandering around the last nav target until animation stops. Any hints on how to blend the root motion and animation from walk to stop and vice versa would be welcome.

    (3)
    And lastly you mentioned that in [PAR] node when any child node fails the whole tree is reset. Does this behavior apply to any other nodes ? For [SEQ] when any child node fails I would expect that it just exits the [SEQ] node and proceeds with consecutive nodes (as I actually did for the [PAR] with fail=any).

    And once again thanks for your tips so far. They helped a lot ! I really want to excercise my example until I understand it completely before going to the wide open.

    #37518

    prime
    Keymaster

    1) If the AI are ignoring the nav mesh then it probably means (a) you have “Allow Off Graph Movement” checked, and (b) your nav target is not on a reachable nav mesh.

    2) RAIN doesn’t do anything at all with sound. Must be something else with how you have sound set up (e.g., are the sounds 2D or 3D sound? How is your fall off set up? Where is your audio listener located?)

    3) RAIN doesn’t currently support dynamic obstacle avoidance. If the truck is within the walkable nav mesh then AI will sometimes walk through it.

    Make sure your nav mesh visualization looks correct, has holes in the right places, and represents the valid walkable regions. In most scenarios, you will want to turn “Allow Off Graph Movement) off.


    Draco Nared
    Participant

    Hi!

    First of all, I want to say that RAIN is magnificent tool and spared me a lot of trouble making AI on Unity’s builtin Navmesh. However, I stumbled upon a major issue that I have no idea how to cope with.

    My AIPawn uses a script in which it moves to a last location of player when it loses him/her from its sight. Usually it works, but there are situations when the chosen path to the target is a floor below. In the first pic you can see that DrawPaths chose a path a floor below, while in the second it is trying to move through a wall.
    Draw Paths shows that the chosen route goes a floor belowBut the AIPawn walks into the wall
    Sometimes it chooses a way around, going down to the floor below and then to the target (like in the first pic).
    Strange route
    There are no issues in the Behaviour Tree, in 2D environment (only one floor) it works great. However, in situations like this, it goes nuts. Also, there is only one big navmesh on scene.

    Here’s the fragment of code that sets the location for the AIPawn.

    public class MoveToLastKnownPosition : RAINAction
    {
        public override void Start(RAIN.Core.AI ai)
        {
            base.Start(ai);
        }
        public override ActionResult Execute(RAIN.Core.AI ai)
        {
            GameObject go = GameObject.FindGameObjectWithTag("Player");
            ai.WorkingMemory.SetItem<Vector3>("moveToLocation", go.transform.position);
            return ActionResult.SUCCESS;
        }
        public override void Stop(RAIN.Core.AI ai)
        {
            base.Stop(ai);
        }
    }

    I don’t know what to do so I am asking for your help.

    #36118

    prime
    Keymaster
    #35907

    In reply to: RAIN for 2D


    prime
    Keymaster

    RAIN doesn’t support 2D well. The movement systems in RAIN are fixed to the 3D y-up axis. It’s on the roadmap to support arbitrary axis in RAIN, which would then allow us to support 2D, but we haven’t gotten to it yet.

    #35899

    OliverA
    Participant

    Hi all!

    Just started a new 2D project, and I am sure this has been asked before, but is there an easy intergration with RAIN into a 2D game. If anyone has any resources or tips that’d be much appreciated.

    Thanks!

    #35748

    prime
    Keymaster

    Awesome. Glad you got that working. Two quick tips:

    1) The “Override Root Motion” field is actually “Override Root Motion Rotation”. This allows RAIN to adjust the rotation of your character after your root motion animation plays. If you have good root motion turning animations in your Mecanim State Machine, then you can leave this unchecked (false).

    2) Let me put in a plug for our Sentio Characters. They’re only $15 on the Asset Store, and are pretty good reference models for more advanced rigging. The Sentio Darkness Warlord character available today has a state machine that switches between walk, run, and strafe animations. We’ll also be releasing a new Sentio Minotaur asset later this week. The Minotaur has a more advanced state machine with full 2D locomotion blending. These aren’t root motion, but the setup is the same anyway.

    Sentio Character info available here: http://rivaltheory.com/sentio/

    #35460

    In reply to: RAIN FAQ


    prime
    Keymaster

    Much of RAIN is based on 3D environments and characters. The Basic Motor, Basic Navigator, sensors, movement functions, and AI Kinematic all assume a y-up 3D axis. Out of the box, some features are not compatible.

    However, many developers have successfully integrated RAIN into 2D games. You can still use the behavior tree system, the Basic Mind, the Memory system, and the overall structure of RAIN. If you do want to integrate movement, sensors, or pathfinding, you can build 2D replacements for the motor, navigator, and sensors and plug them in.

    #35459

    In reply to: RAIN FAQ


    tleedz
    Participant

    Does RAIN work with a 2D platform “mario” type game?

    #35075

    In reply to: Custom Nav Mesh


    urpro-bas
    Participant

    This is pretty interesting I have been busy with generating my own navmesh as well. When I started working on this I looked at the forums to see if there was anything of help for me. At that time I only found the runtime generation example which just does the same as the generate button but at runtime (this helped me a little bit), but it was way too slow to use for my application. My generated level actually is pretty simple, so I could define the mesh myself if I had to so I tried that. Besides I am not sure how the stitching in the example above would work if the navmeshes do not exacly line up, but have some overlapping space.

    I came across some facts that to my knowledge are not documented but are good to know when you are getting into manually messing around with navmeshes. Maybe Sigil could validate those discoveries for correctness and completeness.

    Some of the info I show could be derived from the code sample from Sigil.

    • NavMesh definitions can be made with ContourMeshData (using RAIN.Navigation.NavMesh.RecastNodes.ContourMeshData)
    • Contours are Polygons
    • Contours have to be convex
    • Contours and Triangles have to be defined with left turns (the ordering of vertex indices)
    • ContourMeshData.Triangles and ContourMeshData.Contours are 2d int arrays
    • ContourMeshData.Triangles and ContourMeshData.Contours are vertex indices
    • The first dimension of ContourMeshData.Triangles and ContourMeshData.Contours is the Contour
      1. So ContourMeshData.Contours[x] defines the border of the Contour with vertex indices
      2. So ContourMeshData.Triangles[x] defines all triangles of the Contour (triangulation of the polygon defined by the contour)
    • The second ContourMeshData.Triangles contains all triangles for the contour in set of three (so you could actually imagine it as a 3d array where ContourMeshData.Triangles[contour][triangle][vertex], but this [triangle][vertex] part is merged)

    I think I have summed up my discoveries now, I hope this can be useful for other people working with the navmesh, but unfortunately, this is all going to change as Sigil already mentioned.

    • This reply was modified 6 months ago by  urpro-bas.
    • This reply was modified 6 months ago by  urpro-bas. Reason: oops ul inside ul doesn't work
    #35064

    prime
    Keymaster

    Good questions. RAIN isn’t really built for 2D. We’ve been wanting to add 2D support for some time, but just haven’t been able to get to it yet. Here are some of the difficulties:

    1) 2D usually uses a different coordinate system. RAIN is build on the standard Unity 3D coordinates and makes some assumptions there in a few places.
    2) RAIN doesn’t recognize 2D geometry or colliders when doing things like generating navmeshes, raycasting, etc.
    3) Although you could work around these issues, you will probably need to create your own Motor and Navigator to do so.

    Things that should generally work regardless of 2D/3D:
    1) AI Memory
    2) AI Behavior Tree
    3) Entities/Aspects/Sensors that don’t do raycasting and use radius detection only.
    4) Mecanim support
    5) Audio support
    6) Custom AI elements

    On the one hand, it isn’t terribly difficult to write a 2D motor and navigator - much simpler than the 3D case - but on the other hand it does require some knowledge of RAIN. You are also free to use the HeuristicSearch class for your A* pathfinding.

    If you decide to use RAIN, reach out to us directly (support@rivaltheory.com) when you have questions/issues.

Viewing 15 results - 1 through 15 (of 58 total)