I have a combat animation in my game and I want my hitbox to follow the animation. I have tried using the record feature, but it has not been working. Is there any other ways I can have my problem fixed.
Colliders get animated with the animation itself and moves accordingly. Make sure that the object you are animating has a collider on itself not on its parent.
Related
so recently I started working with Unity animator, pretty cool, but got an issue.
I want to play "walk" animation and whenever preson gets a gun play another "hold" animation.
I tried to make 2 layers with usual walking and beneath it gun holding animation, but it just overrides with gun holding animation.
Any ideas?
Edit: screenies
As KinyL states, you need to add an Avatar Mask to the upper body layer. In the Mask, uncheck the lower body elements and you'll be good to go.
I am currently working on a unity project and I have a stickman built by Hinge Joints but when I animate his legs and activate the animation, the legs stays at the same position and the rest of the body is moving forward.
How can I animate the legs without freezing it's position?
This worked for me:
Anchor and Axis should be correct, if it works with a motor.
For testing, deactivate "Use Spring", "Use Limits" and "Use Motor".
If it still doesn't move, you should have a look at the rigidbody. "Is Kinematic" should be deactivated as well.
From here
A lot of time passed since I asked this question and when I read this question again I figured out that my mistake was animating the legs without a parent.
The legs hadn't a parent so their positions where the animation position.
But if I had setted the legs as children of an empty game object, their positions were relative to the empty game object, which I could move as I wish.
I have a GameObject for Chest(with Collider and SpriteRenderer)
By default it is a static sprite on the screen
now i want to add animation to this game object when open is triggered (by script), I do not have Idle animation, idle animation must be the sprite itself
what is the best to add an animation(no looping, 1 time and then show the animated sprite) to sprite?
I can do it by adding the sprite array and using an coroutine to set the sprite periodically with 0.2f delay (it work fine but not sure if it is the only way which using coroutine with delays to simulate an animation by myself...).
I can do it by create 1 more GameObject with the Animator, when the box open event is triggered, I set the original GameObject to inactive and instantiate the GameObject with the animation (but it requires to create 2 prefabs for two different gameObject).
But none of them look proper way to do this. What is the best solution for this?
I am using player prefab from SteamVR Plugin. Whenever player touches an object with a Collider on it, camera sees through it. I am using 0.01 as minimum clipping value. I have also added Rigidbody and Collider on camera.
I also do not have code currently but here’s a concept of how to approach the problem:
Keep a trigger collider on the camera.
Write a script that detects when that collider is within another collider (your walls). There is a method for checking if colliders are intersecting/overlapping
If there is an intersect/overlap, fade the camera to black. If there is not, fade back.
I made a button that is clickable during the game playing. As I want the button have a fixed position in the main camera, I made both the main camera and the button children of the player gameObject so that the camera will follow the character while jumping or moving, everything works fine but there also a border colliders which will prevent the character moving out of the playing area. But then the collider of the button which was made intend to make the button clickable will also collide with the border which will prevent the character moving right forward. If we set the collider of the button a trigger, it seems that the button will be triggered wherever I click the mouse on the screen, that's not what I wanted.
I know maybe I could prevent this by checking if the collided object is the button or the character, but is there a better way to do that? Thanks.
For a 2D platform game, I would add a 2D user interface in a canvas over the "map" (the layer where you have the gameobjects like the character, platforms, enemies...). So the button will be always in the same place of the screen and will never collide with any gameobject of the game.
You make take some ideas from here: https://unity3d.com/learn/tutorials/topics/user-interface-ui/ui-events-and-event-triggers
Try use new UI in Unity may it fix your issue:
https://unity3d.com/learn/tutorials/topics/user-interface-ui/ui-button