GameObject does not rotate using TwoHandManipulatable nor BoundingBoxRig using Unity and HoloLens - visual-studio

I have a GameObject in a Unity project for HoloLens with HoloToolKit, which I need to rotate. The object has a BoxCollider and HandDraggable script, and I'm also adding a TapToPlace component in runtime. The scripts that I've tried for rotation are TwoHandManipulatable and BoundingBoxRig, and they work to resize the object, but no matter what I do, the object does not rotate.
This is how I tried with BoundingBoxRig:
And this is how it looks with TwoHandManipulatable:
None of these works, only for resize. I would appreciate the help, thanks!

For me all I had to to to get it to work was to add the Transform of your arrow2 to the box of the Two Hand Manipulatable. Just click and hold on Transform and drag it into the box next to Host Transform. I added it to my project and it looks like this:
Also I don't think you need the Hand Draggable Script if you have the Two Hand Manipulatable because the last checkbox in the Two Hand Manupulatable enables movement with one hand if you want it.
Edit: I have an Animator on it but you don't need that. I have it because I made the model in Blender and it got added automatically.

Related

HoloLens - UI/Slider and Cursor do not intersect during gaze

I'm trying to use UI/Slider in Unity app for HoloLens.
I used the steps described here - Unity UI on the HoloLens
So as a result I have following structure:
MainCamera properties:
SliderCanvas is using MainCamera:
Slider properties:
InteractiveMeshCursor is taken from HoloToolkit.
As a result I'm getting this picture:
When I move the head the Cursor behaves correctly - it stays in the middle of the scene. If I add other 3D objects on the Scene it also correctly changes its states so GazeManager looks like is working correctly.
However I cannot gaze at Slider because it moves with the Camera too and stays in the bottom/center of the scene where I want it to be. So in my case there is no way for them to intersect.
How can I fix this? Do I need to add an other Camera for the SliderCanvas but then how to control both cameras? I am definitely missing something and would appreciate your help.
As expected the solution turned out to be simple (I missed one step from the tutorial). For UI objects you need to set Render Mode property for the Canvas to World Space and changed the Position and Scale of the Slider. Now the Gaze is working.
SliderCanvas properties:
Slider properties:

What is the better form to animate on Unity 3D?

I would like animate a object similar 3D sequence diagram using Unity 3D. I donĀ“t know what is better form to animate, if Animation or Animator...
So, I do a preview on Power Point https://youtu.be/tgfPIT47xGY
Animation vs Animator:
The Animation component is an old component used for animation in our legacy animation system. It remains in Unity for backwards compatibility but you should not use it for new projects. Use the up-to-date Animator component instead. SOURCE
Use the Animation Editor View for this.
To animate Game Objects in Unity, the object or objects need an Animator Component attached. This Animator Component must reference an Animator Controller, which in turn contains references to one or more Animation Clips.
When using the Animation View to begin animating a GameObject in Unity, these items will be automatically created, attached and set-up for you. SOURCE
Though slumtrimpet is obviously right, I can't see why you might need animations to create something like the video you shown. Why don't just use sequential instantiates with the help of coroutines or simple timers?

Unity - How To Animate UI Text Smoothly?

I just wanted to know how do you transition a UnityEngine.UI from one position to another smoothly?
My current code is this:
GameObject rank1;
GameObject rankSlot1;
rank1 = GameObject.Find("Rank1");
rankSlot1 = GameObject.Find("RankSlot1");
rank1.transform.position = new Vector3(Mathf.Lerp (rank1.transform.position.x, rankSlot1.transform.position.x, 0.1f), rankSlot1.transform.position.y, 0);
But it seems like the Mathf.Lerp doesn't work :/
Thanks!
EDIT: All these gameobjects do have Rect Transform as they are a children of Canvas
It depends where do you use Lerp ? Are you calling it once ? or in Update(). Calling in update with correct parameters should work.
Beside Lerp, you can use Animator component with position curves to move from one point to another.
There is another option to use LeanTween plugin, it is a free plugin on asset store.
LeanTween.move(gameObject, yourFinalPosition, duration);
If using an animator you get access to the animation curves so you can get really nice controlled animations
Tricky part is if you are wanting to use 'apply root motion' (have the animations start where they are instead of fixed positions) you need to apply it to something that is considered ROOT:
- create an empty gameobject - with a normal transform
- parent the canvas with text to this new gameobject
- apply the animations to the gameobject transform ( not the UI rectTransform)
- on the animation in the inspector you should now be able to click on the 'generate root motion curves' and also select the 'apply root motion' check box for the Animator
hope this helps,, took a few hours to get working :) I used this to float up enemy damage text displays

Unity Animation not working on different scene

I'm working on a menu scene where the options come down from top, so I tried to use Unity simple Animator. The problem is the animation won't work. The weird part is, when I tried the same thing on my game scene the animation works.
-I've checked that the animation is attached to the object
-Culling type is Always Animate
-I've also added a script and tried to force the animation with no results.
Why doesn't the animation not working anything other than the main scene? Do I need to trigger something for it to work?
Things you could check:
Make sure you are using the same kind of component in both scenes. Animator is different from Animation.
If you have an Animator component make sure you have an the right Animation Controller attached to it.
If you have an Animation component make sure that the Animation field is set and holds your animation file and Animations is set too and holds the list of possible animations of your (UI) object.
Even though they have the same extension, .anim files created when an Animation component is attached are different from .anim files created when an Animator component is attached so if you try to play an Animator .anim it won't play with an Animation component.
Is your Animation set to play automatically? If not, are you giving the animation.Play() command somewhere in your code?

animation not playing unity

This appears to be such a common problem, that finding answer to my specific case is near impossible, because of the amount of noise in google or forum searches.
I have imported object to unity from blender. This objects had smaller objects inside it. Those smaller objects have animation on them, which was created in unity. If I open the animation window (Window->Animation) and press play - I can see correct movement of an object. Animation is set to play automatically in inspector, culling type is always animate. If I play the game however, animation does not play. Why?
add the animation to the main object, then animate the smaller object...
you have to put animation component to main object, then animate the small part...
it is important...
it should work
I Could not find any unity inspector based answer. For now, the best option I have is to create new script, and in update() check if the animation is playing. If not, play it. Very inefficient, so to whoever might stumble upon this post in the future, I suggest you try to add this.animation.play() in setting up part of the script.
I know it's kinda late, but this is for others having this same issue.
Animations in Unity have types (2 of which I know).
Type 1 can be attached to an object using the Animation Component.
Type 2 can only be used in Animators (Mechanim).
Animations imported with FBX files are type 2 (and as far as I know, animation type in FBX files can NOT be changed), so they will usually not work when attached directly to an object with "Animation". They should be used with Animators and Animator Controllers. Just create a New Controller and add the animation. It will become the default animation state and play automatically.
If you want it to loop, click on the FBX asset, and in the Animation tab, choose Loop Time and click Apply.

Resources