News › Forums › RAIN › General Discussion and Troubleshooting › A newbie needs help
This topic contains 4 replies, has 2 voices, and was last updated by prime 3 years, 3 months ago.
-
AuthorPosts
-
December 19, 2022 at 11:46 am #5985
Hello,
After a long night of struggling with creating a custom action for my objects in Unity, I decided to write my problems here.
I’m a total newbie to not only RAIN, but also Unity; I’ve tried learning stuff from tutorials here and there, but never with a good results. Recently I decided to have some alone time with Unity and effects are better than with tutorials honestly. I’m on my third day with Unity today.However, I downloaded RAIN to try it and it’s amazing! I love your AI system and I believe only you can solve the problems I’m stuck with.
Look, I’m not a total noob with programming, I’ve been programming in PHP, Javascript and Java for a while now, so learning scripting in Unity doesn’t give me much trouble. I just don’t get some things:
I ha
I have a cannon that is supposed to turn around it’s own Y axis. If I understood it correctly, in RAIN{Indie} you made an Agent instance and have it move and rotate the object in the game. In new RAIN version, it’s been replaced with ai.Body, so I have a following code:import UnityEngine; import System.Collections; import System.Collections.Generic; import RAIN.Core; import RAIN.Action; @RAINAction class seekingOut extends RAIN.Action.RAINAction { function seekingOut() { actionName = "seekingOut"; } function Start(ai:AI):void { } function Execute(ai:AI):ActionResult { /* This is where the cannon is - I think - supposed to be rotating */ ai.Body.transform.Rotate(Vector3.up * 2 * Time.deltaTime); Debug.Log(Vector3.up + " | " + Time.deltaTime + " | " + ai.Body.transform.rotation); return ActionResult.SUCCESS; } function Stop(ai:AI):void { super.Stop(ai); } }
And my gun is still. Why is that? What am I doing or understanding wrong? All tutorials on the Web are about scripting with RAIN{Indie}, so I couldn’t get a proper knowledge I guess.
- This topic was modified 3 years, 3 months ago by EnslavedEagle.
December 19, 2022 at 2:35 pm #5989In your code, you are rotating the body directly. However, RAIN is also trying to control movement and is overriding your changes.
Is your cannon just rotating randomly or constantly, or are you trying to rotate it toward something?
December 19, 2022 at 3:26 pm #5991Thanks for reply, Prime.
My cannon’s AI has only one behavior set, and it’s the one I posted above. There is no other movement script set for the object.
My goal is to make the cannon rotate as if it was seeking out for enemies, and if enemy is within it’s sight, focus on it and rotate towards it. But for now, I’m stuck with just making it rotate 45 degrees left and right.
- This reply was modified 3 years, 3 months ago by EnslavedEagle.
December 19, 2022 at 3:59 pm #5993Edit is gone, sorry for doublepost
I realized that I could use Move Action instead of a custom script, but I encountered different problem. I try to assign two move actions that will execute one after the other;
First move just makes my cannon face Y:45 degree angle and the second one makes the cannon face Y:-45 degree angle.
The first move executes perfectly, but the second one is just skipped. Why is that? I tried to set Move Actions into a sequencer (which I think is made to execute one action after another), a group of sequencers into one sequencer, I tried with priorities but that didn’t work either and an iterator that would loop a sequencer with two Move Actions. What am I doing wrong now?
BTW, sorry if my English is sometimes unbearable, I do my best to express myself as clearly as I can.
- This reply was modified 3 years, 3 months ago by EnslavedEagle.
December 19, 2022 at 5:02 pm #5996You should be able to do this with a sequencer and two moves, as you mention. I would probably use Navigation Targets to specify the two sides of the rotation, then set them as FaceTargets for each move.
-
AuthorPosts
You must be logged in to reply to this topic.