News Forums Search Search Results for '2D'

Viewing 15 results - 16 through 30 (of 52 total)
  • Author
    Search Results
  • #30996

    Adam
    Participant

    I have been developing a 2D game for some time, using RAIN for the AI and A* Pathfinding project for navigation.
    In the name of good software development practice I have been developing reusable RAIN actions for use in
    my BTs. I have decided to share some. First up is an action that allows you to call a method on a component attached to the body of an AI. I have found this extremely useful for simple tasks like playing effects and such as it allows you to perform a custom action without creating a new class.
    I hope someone finds this useful.

    
    using UnityEngine;
    using System.Collections;
    using RAIN.Action;
    using RAIN.Core;
    using RAIN.Representation;
    using System.Reflection;
    using System;
    [RAINAction]
    public class CallMethod : RAINAction
    {
        public CallMethod()
        {
            actionName = "CallMethod";
        }
        //The name of the component which has the method to call. This should be attached to the AI.Body gameObject. 
        public Expression TargetComponent;
        //The name of the method to call.     
        public Expression TargetMethod;                
        //cache the method signature to avoid expensive reflection calls.
        private MethodInfo _methodInfo;
        private object _component;
        //cache the target names so that we can test if they change
        private string _previousTargetComponent = "";
        private string _previousTargetMethod = "";
        public override void Start(AI ai)
        {
            //test if target has changed
            bool targetComponentChanged = string.IsNullOrEmpty(_previousTargetComponent)  ||
                                         _previousTargetComponent !=  TargetComponent.ExpressionAsEntered;
            bool targetMethodChanged = string.IsNullOrEmpty(_previousTargetMethod)  || 
                                         _previousTargetMethod !=  TargetMethod.ExpressionAsEntered;
            if (targetComponentChanged || targetMethodChanged || _component == null || _methodInfo == null)
            {
                //get target component type
                Type componentType = Type.GetType(TargetComponent.ExpressionAsEntered);
                if (componentType != null)
                {
                    //get the target method signature
                    _methodInfo = componentType.GetMethod(TargetMethod.ExpressionAsEntered);
                    //get the target component
                    _component = ai.Body.gameObject.GetComponent(TargetComponent.ExpressionAsEntered);
                    //update target names
                    _previousTargetMethod = TargetMethod.ExpressionAsEntered;
                    _previousTargetComponent = TargetComponent.ExpressionAsEntered;
                }
            }
        }
        public override RAINAction.ActionResult Execute(AI ai)
        {
            if (_methodInfo == null || _component == null)
            {
                Debug.LogError("RAINAction.CallMethod has failed: Cannot find method to call.");
                return ActionResult.FAILURE;
            }
            //invoke the methods
            _methodInfo.Invoke(_component, null);
            return ActionResult.SUCCESS;
        }
    }
    

    Adam


    nintendoeats
    Participant

    My current project is a Doom Clone, in the particular sense that it represents objects through 2D sprites instead of 3D models. I have been experimenting with Rain to handle the AI, and I’ve been happy with it. However, as I’m still figuring out the workflow I’m struggling to come to terms with how to do this sort of animation. I’ve been experimenting with using a custom script to communicate with RAIN’s AI and swap animations based on whether the NPC is walking or firing, but I’m getting a strong sense that I’m working against the systems’ intent. Which method of doing this is most suited to RAIN’s workflow?

    Thanks in advance!


    mcshinigami
    Participant

    I’m new to all this (I’m a sound guy) so I apologize if this is a silly mistake, but in my game right now I’m trying to set up a really simple pathfinding waypoint system where the AI just walks back and forth in a 2D environment. The problem is that the AI moves to the closest waypoint and then just stops. I have a YouTube video you can view of it . I saw a similar post where someone said you need to wrap the AI node in a empty parent object which I believe I did, unless of course I did it wrong. In the video I tried to show all the settings you might wonder about. I’m just trying to learn this system in hopes I can eventually create an AI that chases the player character when they are seen/heard. Hope I’m on the right path! Thank you.

    #9363

    In reply to: Rotation face problem


    Pavel
    Participant

    If Player detect enemy and keydown f, he get knife(anim and knife “up” and visible true) and “fastkill = true” that is in Rain -> he move to Enemy(now he stay, but anim is playing, because aimtarget = null(why? in rain 2.09 it’s ok) and then if near trigger have success play knife kill anim and take damage enemy(play anim too and then go to ragdoll -> in Health script).

    I have tried all possible options “Repeat” in Rain Behavior but still periodically get this bug.

    Two of them “Repeat” options have in the picture

    • This reply was modified 1 year ago by  Pavel.
    • This reply was modified 1 year ago by  Pavel.
    #8942

    In reply to: 2d NPC Sprite Issue


    prime
    Keymaster

    Sure - You will need to do 2 things:

    1) Make sure the AI Motor is set with a Face Before Move Angle of 360. This will allow it to move without facing in a particular direction.

    2) Add a Face target to your AI. To get this to really work well, you may want to consider parenting an object to the AI that moves with it, and then set that as the face target. Alternatively, you can set your rotation speed to 0 and it just won’t turn at all.

    RAIN isn’t really built for 2D games, so you may have to perform little hacks like this from time to time.

    #8826

    In reply to: 2d NPC Sprite Issue


    markhuntley
    Participant

    Hi Guys,

    So even tho Zeul seems to have resolved his problem this is something I am looking into doing as well if I understood his problem properly.

    The sprites that I am working from are facing forward ( similar to http://tinyurl.com/pyfwy5d) but when I get rain working there head starts pointing in the direction they are moving rather then staying vertical and just moving.

    Is there a way to lock the sprites rotation or to stop rain rotating the gameobject. I have googled this and i cant find anything on your forums that helps. I did find a few comments saying that you will be working 2d sometime this year. Is this something that it is worth me waiting for or are we talking later on?

    Thanks in advance.

    #8751

    Zeul
    Participant

    Okay first before I begin
    I want to congratulate everyone @ RAIN
    for an outstanding product.
    okay well I’ve gotten my npc in unity walking around with the way points
    it works no problem…but the orientation of the sprite animation is off.
    what I mean by off is the npc is a 2d image but when walking …it flips the
    2d image sideways in the direction it is walking thus making the image lol
    look very thin and nearly disappears ….soooo how does one maintain quality
    with just having it simply walk sideways to display the whole image…do I
    need to have another constraint to force the image to display a certain way?
    I’m sure this is a simple fix but I lack the work around knowledge to preform the fix.
    mind you on a good note the only time my 2d character is displayed correctly is when it
    turns in the opposite direction ….at that point the orientation is great but only for a moment
    then it returns to a skinny image :)
    thank you for all your time and patience

    #8643

    In reply to: Rotation face problem


    Pavel
    Participant

    My xml BT and picture with description one problem and i have maybe all problem post above
    BT xml and img:
    https://onedrive.live.com/redir?resid=2D44618B7C8CAAE5%21123

    • This reply was modified 1 year ago by  Pavel.
    • This reply was modified 1 year ago by  Pavel.
    #7527

    Jester
    Keymaster

    One of most successful videogame Kickstarters of 2013, raising 1.8M of their 400K goal.

    ShadowRun Returns

    Shadowrun Returns

    Shadowrun started as a very popular role-playing board game in the late 1980s; the franchise has grown to encompass a collectible card game, a series of novels and several video games in the mid-90s. Jordan Weisman, the game’s creator, returned to bring ShadowRun into the new generation with an old school twist. “Shadowrun Returns” won’t be a 3D graphic-packed video game like most titles on the market today. Instead, it will feature 2D graphics and multiplayer featuring community-created maps and stories for a more intimate experience.


    Read more about Harebrained Schemes’ amazing game and how they used RAIN.

    About Studio Showcase

    Studio Showcase is a free program where we promote games using RAIN to thousands of players, artists, and developers that are waiting to see the next great idea. Your idea. Apply for your very own Studio Showcase here!

    #7271

    In reply to: Mecanim Generic rig


    norbykov
    Participant

    Thanks for taking a look at the project, I appreciate you taking the time to do it.

    The thing is, the dino is walking forward correctly. I know its setup is far from being conventional, and the 2D blend tree is just for testing, but except for the weird blending, it’s working pretty well animation-wise. Actually, somehow I got it to walk towards a navigation target, and as I move around the target, it’s walking towards it correctly, but it doesn’t stop at the nav target, just walks on if it gets there.

    Not quite sure where to go from there, but I’ll keep looking, and if I find something, I’ll post it here.

    Thanks again!

    #7236

    In reply to: Mecanim Generic rig


    prime
    Keymaster

    So I took a look at the project. Lots of issues there.

    - Your Controller state machine doesn’t make sense. It probably should just be a simple 1D blend based on speed. You are currently doing a 2D cartesian blend and you are blending between Walk animation and an in place action (non locomotion) animation. You get silghtly better results if you switch to 1D and blend between Walk and Run.
    - Your animations and model aren’t right. The animation isn’t looping correctly, and it is rigged to walk in the wrong direction. You will save yourself a lot of headache by going back and setting up the animation and exporting it correctly.

    You should be able to test out your animation, model, and state machine completely independently of RAIN, then only hook it into RAIN after it works. For example, put a non-RAIN dino in your scene, run the scene, and then manually adjust your Forward parameter. If the Dino walks forward correctly, then consider letting RAIN take over control.


    Eduard Gotwig
    Participant

    Hey, I cant get the tutorial 3 working, can you take a look pls? I tried to integrate them into a seperate project, my game project

    I removed the bought proprietary assets, I hope that doesnt make big problems, here is my game project:

    https://mega.co.nz/#!804iDSDZ!oKokln1hGVNnuZpgEsUV0mnAoZf2D66HPFQRbHkLsjg

    #6697

    In reply to: Rain and 2d


    Feddas
    Participant

    Just posting to show additional interest in 2D support coming in RAIN.

    #6599

    In reply to: Rotation face problem


    Pavel
    Participant

    Yes I make 2d game(with 3d graphics), and do nothing? Are you add change face angle in future?

    #6595

    In reply to: Rotation face problem


    prime
    Keymaster

    Looks like you are making a 2D game. Currently RAIN only manages character facing and movement when the world axis is Unity 3D default (Y up).

Viewing 15 results - 16 through 30 (of 52 total)