crouch attack collider 2d question
i'm making a 2d sidescroller and right now everything is working perfectly, up until now anyways. my character can attack just fine. I have a gameObject prefab that initiates and kills itself, but does damage to an enemy if it collides while it exists. It spawns from a Transform gameObject that I linked up to the character, much like you would with a groundCheck. Like you drag the indicator that's beneath the feet of your character. So far, so good. But here's my latest conundrum. When I duck, the indicator that tells the collider where to spawn, doesn't follow the character when he crouches. I can attack, but the location of the attack is in the same position as when my character was standing, even though the indicator has followed the character. I set it up that way in the animator. So my question is, how do I get the collider to follow my character's crouching state, so that the attacking is at a lower height? Like, what do I have to look up or learn in order to perform this task correctly?
Answer by Zynek · Oct 28, 2016 at 05:32 PM
You could simply add two Vector2 to your script. One representing position when your character stands and second when he crouches. Then you would reposition the indicator based on the state that your character is in.
You could also just make second indicator and use it when you´re crouching, but the first solution is better because you can interpolate and therefore make transition smoother.
Your answer
Follow this Question
Related Questions
Dash through enemies and dont taking damage 3 Answers
How to find all GameObjects in Hierarchy by name and put them in an Array[] ? (C#) 1 Answer
How To Add Multiple 2d Box Colliders on Same Object for Different Effects 0 Answers
Collision inside a local function 2 Answers
Spawn from GameObject C# 0 Answers