-
Search Results
-
Topic: RAIN Actions
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
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!
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.
Topic: 2d NPC Sprite Issue
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 patienceOne of most successful videogame Kickstarters of 2013, raising 1.8M of their 400K goal.
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!
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