News › Forums › RAIN › General Discussion and Troubleshooting › Mecanim Damage?
This topic contains 12 replies, has 4 voices, and was last updated by Royal Allen 2 months, 2 weeks ago.
-
AuthorPosts
-
January 1, 2023 at 4:06 pm #34956
Hi Royal Allen first time at the community.
Anyways my question is how do I send damage to my Ufps chacter. I have my Rain Ai rig, waypoint, Detects, and Attack all set up. I have a script to do damage. So how do I do damage with mecanim or custom scripts?
January 3, 2023 at 7:10 am #34976I’m not familiar enough with UFPS to answer the question. How do UFPS characters typically receive damage?
January 3, 2023 at 5:10 pm #34980http://visionpunk.vanillaforums.com/discussion/650/send-damage-to-player
Gives you some info about how the damage handler works in ufps.
http://docs.unity3d.com/Manual/animeditor-AnimationEvents.html
Tells you how to setup an animation event.
You could use this to send a message to the player damage handler to deduct a specified amount of health.
I will be doing something similar myself in my own project soon in the next week so if you need any more help give me a shout and I will do my best
January 3, 2023 at 5:13 pm #34981There is also this thread
http://rivaltheory.com/forums/topic/sample-project-rain-attack-harness/
Which may or may not help you in conjunction with the ufps event system. I haven’t had a chance to experiment with it yet.
Good luck
January 5, 2023 at 3:30 pm #34987@Prime They are handled through the Damage Handler for the Ufps. But I was following the Rain Ufps tutorial on YouTube. But I am not quite sure how to code it in the custom script. But ufps manual states to do damage to player you write
thishitObject.SendMessage(“Damage”, 1.0f, SendMessageOptions.DontRequireReceiver);
January 5, 2023 at 3:39 pm #34988Thanks for the links. I’m not using legacy animations so its alot different. But I been trying to go that route. I learned mecanim events are sent when you setting animation there’s a little button to add an event. But I get lost on trying to send damage through mecanim animation state.
- This reply was modified 11 months, 2 weeks ago by Royal Allen.
January 6, 2023 at 9:10 am #34993What exactly are you trying to accomplish? When/where are you sending the damage? Is this happening when the AI performs some action? When an animation plays? When an animation gets to a certain frame? Who is receiving the damage?
Typically the process is simple, as the
thishitObject.SendMessage(“Damage”, 1.0f, SendMessageOptions.DontRequireReceiver);
code suggests.
Some object will have a monobehavior with a Damage method that receives a float parameter. Are you trying to send the message via RAIN, or receive the message on an AI?
January 9, 2023 at 6:30 pm #35033I am trying to send damage through Rain AI to my target being my player.
But I am not coder so I seem to break it by trying to send it through a custom action.
I wanted to try and send an event through the Mecanim animation.
But instead I am trying to it through a custom Action.
So after the animation plays he shoots at the player.Rifleman(AI) I want to send damage to my player(Target).
I been trying to code into the script. I am go take a look at the api.
Thus I am lost :/.January 9, 2023 at 6:32 pm #35034@Prime
So basicallyExample
BT
.
.
animation
CustomAction(Sends damage to the player through script.)January 10, 2023 at 4:08 pm #35036Okay I sort of got concept with bigfiregames links and I didn’t break anything lol.
Just exprimenting around till I get it. I appreciate the help.
January 11, 2023 at 8:17 am #35045Typically you won’t do anything different in a custom action vs what you would do in any other Unity script. You probably want to do the SendMessage or similar as I suggested. The only tricky part is knowing which object to send the message to. However, if you are sending damage to the player, then you probably detected the player in a Detect node and have the object in ai memory. If so, then your Execute code will simply be:
GameObject tPlayer = ai.WorkingMemory.GetItem<GameObject>("player"); //assuming you store the player object in a variable called player tPlayer..SendMessage(“Damage”, 1.0f, SendMessageOptions.DontRequireReceiver); //assuming you do 1.0 damage
October 1, 2022 at 11:12 am #39263Hey Royal_Allen,
Did you ever get this to work?
I’m considering UFPS, but its ability to integrate with RAIN (and AWAI) are pivotal.Like your work on RA_Missions.
Cheers!
MarkOctober 1, 2022 at 12:33 pm #39265Hi Mark I have actually didn’t finish working with this. But at that time, I didn’t know how to program. But now I do. I will look into it. Thanks about RA_Mission glad you find it useful. I might upgrade it soon. Since Im way better at programming now.
-
AuthorPosts
You must be logged in to reply to this topic.