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.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #34956

    Royal Allen
    Participant

    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?

    #34976

    prime
    Keymaster

    I’m not familiar enough with UFPS to answer the question. How do UFPS characters typically receive damage?

    #34980

    bigfiregames
    Participant

    http://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 :)

    #34981

    bigfiregames
    Participant

    There 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 :)

    #34987

    Royal Allen
    Participant

    @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);

    #34988

    Royal Allen
    Participant

    @bigfiregames

    Thanks 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.
    #34993

    prime
    Keymaster

    What 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?

    #35033

    Royal Allen
    Participant

    @Prime

    I 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 :/.

    #35034

    Royal Allen
    Participant

    @Prime
    So basically

    Example

    BT
    .
    .
    animation
    CustomAction(Sends damage to the player through script.)

    #35036

    Royal Allen
    Participant

    Okay 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.

    #35045

    prime
    Keymaster

    Typically 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
    #39263

    Mad_Mark
    Participant

    Hey 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!
    Mark

    #39265

    Royal Allen
    Participant

    Hi 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.

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.