Not able to translate gameObject when Animation is already added to it using Animator in Unity2D Sprite - animation

I am able to translate the gameObject from one point to other by the OnMouseDrag() Event have no problem in doing that. But when i have added Animation to the GameObject Using the Animator Im not able to handle its Dynamic translate property when the Drag event take place.
Details:-
The Animation that i have create for the Game object is that it gets Translate from the Outer side of the screen to a side of the screen, This happens on the launch of the scene. (This happens properly)
Now when i want to dynamically translate the game object on the mouse drag it doesn't translate. (if i have not added the animator to the object it translate with mouse drag with out an issue)
Can any Tell me why it is so ?
Thanks in advance.

Did you try making Gameobject with animation,a child of an empty Gameobject and then translating that parent gameobject.

Related

How to webgl detach transform control when click another range not transform control

I'm developing webgl graphics with three.js
While I developing, I'm facing something stuck.
I'm trying to detach transform control when I click another range(ex, grid or another objects) not transform control.
I implemented it by checking clicked position.
For example, I set event handler with mouse down and in there, I store that mouse position. Also I set event handler with mouse up and in there, I compare mouse positions both mouse down and mouse up. If two positions are same, I detach the transform controller. However with this implementation, transform controller was disappeared though I clicked transform controller.
I just wanna detach transform control when I click another position not transform control
Does anyone help me please with this issue?
Thank you in advance.

2D Character, left animation is not being accessed

I have issue in Unity with my 2D characters animation. I simply made the animation of it walking right and left. I set things up in the animator, and for some reason the right animation is being accessed, but not the left whenever I press "A".
This is the code part of animation of my PlayerController script:
anim.SetFloat("mSpeed", Mathf.Abs(rb.velocity.x));
Animator Setup
Figured out what to do instead of using left animation, I just used the Sprite Render to Flip.X when the "A" key is pressed. And it works!

Issue with animating ui elements in unity 3d

I've added an animation clip to a canvas which animates position and alpha channel of its children (like buttons etc.). Now I'm gonna play this animation via pressing the play button (one of itself's children) as shown as here:
(Click om images to see in full screen)
I created a trigger in mecanim and sat as the trigger of transiting to that animation but it didn't work. Is there any ways else or was my job correct and did I some mistakes?
Please help, thanks
In the animator window just making the trigger doesn't do anything. You need to set the trigger by getting a reference to the animator and calling SetTrigger("yourTriggerName"). You can call this in the inspector using the UI button's OnClick() method.
Go to the inspector for the play button and scroll down to where you see this:
click the plus sign and then drag the game object with the animator you want to trigger onto the field that says None(Empty) then select the animator from the drop down menu that appears and select the SetTrigger function. Then type in the name of your trigger Exactly. Upper case matters. That's it. It should look something like this when you are done:
Obviously, you will have to use the correct GameObject and trigger name so yours will look a little different.

Unity UI Button not calling the Onclick method

I have a button under a canvas that is suppose to restart the scene. But instead its not calling the intended function of attached script.
On Unity Forums, I found solutions like it should be at higher hierarchy in canvas, and the canvas should have a graphic raycast and so-on.
But it still isn't working, although its on click array detects the intended method it is suppose to call.
Scene Editor with Canvas Selected:
Scene Editor with Button Selected:
Remove the canvas component from your button.
Make sure that there is a GraphicRaycaster on your canvas, and that there is an EventSystem object somewhere in the hierarchy.
(Both should have been added when you first added the canvas, but things get lost)
The screenshot that shows your button being selected, also shows, that you did pick a gameobject for the OnClick event, but you didn't pick a function from the drop down right next to that field, it says no function.
Instead of selecting the C# class, select the GameObject that
btnSceneSelect is attached to.
If btnSceneSelect is not attached to a GameObject, attach it to one
(other than the button).
Taken from this site

Unity apply idle animation to model

I created a model in Blender and posed it the way I want it to look. The character will never move and no animations will ever change.
I exported the character with animations to an FBX and imported it into Unity 3D. After dropping the character into the scene, the character's pose is back to the default take.
How can I force the character to use the pose that I want? Do I have to do it in script or is there a setting that I can change to make it play the idle animation at all times?
Putting your model in the scene will not invoke idle animation, animation and rendering is two separate thing. To always play a certain animation on a model you have three option -
1. Via Legacy Animation -
Select you model in the scene, remove the default Animator component and add a new Animation component. (Animator and Animation are two different component type.) It has an option of selecting an animation clip. Drop your animation clip there and choose 'Play Automatically'.
2. Via Script -
You can add Animation component, attach multiple animation and select which one to play via script too.
You can also do this for meca-anim way which is explained in the next point.
3. Via Meca-Anime
Every model has a default Animator component. It needs an animation controller object to run. Create an animation controller (Click on create button in project view). Attach the controller to the Animator component. Double click on the controller to open Animator view. Drop your clip there and make it as default. The default animation plays automatically now. Using Meca-anime has many advantage over legacy way, which is beyond the scope of this answer. Check the following link instead -
Mecanim vs Legacy Animation

Resources