A-frame render lop and view refresh - render

I am trying to create a First person view in A-frame using the .obj model of a car.
The camera has been positioned close to the driver's seat, and there is a timed interval in javascript that moves the camera position by doing trignometric calculations and moves the camera accordingly.
Here are two problems I am facing
1) How do you make this smoother? Is there a hook for the render loop in A-frame which can be accessed in javascript? I cant seem to find the documentation for it.
2) When I view the above page in VR mode on the phone ( Android 9), the animation created stops abruptly, which works well in fullscreen mode.
The code for the html is here https://raw.githubusercontent.com/CuriosityGym/VRWithAframe/master/templates/class3-models.html
The example can be accessed here http://cgaframe.herokuapp.com/class3
Thank You!

You have a setInterval that fires every 100ms, animating the car at 10fps. That’s why it’s not smooth. Create a component and use the tick method to animate
In addition, you should not animate the camera directy because its position will be overriden by the headset pose in VR mode. Setup and animate a camera rig

Related

How do I put an interactable Canvas onto a 3D game object?

Is it possible to place a UI Canvas onto a 3D object? I'd like to create a cash dispenser machine (for example) with a user interface that can be interacted with. Then there will be keycode locks on doors, touchscreen computers, etc.
How can I display a canvas as a 3D object in the 3D world and still have it interactable? Placing it on a Plane would be good enough.
Yes, it is possible. Change Canvas Render Mode to World Space then drag your Camera into the Event Camera slot. You will have to find select the Canvas, press F in Scene View to find it then move it to the place you want it to be.
You need to use World Space UI. Can place anywhere in scene but make sure use can view it in order to interact.
To learn more, watch this video : https://blogs.unity3d.com/2014/06/30/unity-4-6-new-ui-world-space-canvas/

Unity3d Updating position with animation simultaneously

I have an animation for humanoid models to simulate climbing. I have been looking for a way to stimulate this animation when the model comes next to the window. I used the triggers to determine where the model is and it worked. However, when I execute the animation, the position of the model is not being updated according to the animation. I am using offmesh links and nav mesh agent and I disable nav mesh agent when the model triggers. How can I use the animation and provide the update simultaneously?
Animation Properties
Thanks in advance.
I don't think the animation should take care of the movement. You should control that somewhere else. You could make the animation climb from y = 0 to 5 but then it won't work if your ladder is at y = 3.
You'd better have a method that is called from the animation using AnimationEvent so that when you trigger the animation, it also triggers a movement of the object upwards/downwards regardless of the current position of the object. It would simply use Translate and disabled input until the animation ends.

Unity Image Component for 2D Animation

I'm developing a 2D game in Unity (Version 5.1.2) which has an animation.
The animation is generated by flipping through the sprites in the sprite sheet.
My problem is that the animation is playing as it should in the "Scene View" but not in "Game View".
I normally create animations by using the sprite editor and then drag & drop all the sprites on the screen (Scene View).
It creates a Sprite Renderer to switch the sprites but I would like the Image Component to flip through the sprites. It seems like only sprites in the Image Component is being displayed in the "Game View".
Is there any way I can get some assistance on this please.
Its really strange that you are only seeing that in your Scene View. If the animation is your default animation? Otherwise, make sure that you are sending the right parameters to your animator. A good way to test it is opening your Animator windows, checking all transitions, and manually filling the parameters to see how it works wile the game is running. Also, check if the transitions between animations has exit times and transition durations, and disable them.

Threejs Rotating object with device orientation control

I am trying to achieve an effect similar to one of the cardboard app examples that Google has put out with their cardboard app called the 'exhibit'. I have a 3D object that I want to rotate using device orientation control. Right now with just the device orientation control, I can view the 3D object but when I turn around, the camera rotates (it seems) causing the object to fall out of view until I turn all the way back around to where it was in the beginning. In other words the camera seems to rotate in its axis as I look around. What I want is to be able to rotate the object as I turn around.
Kinda like this example http://threejs.org/examples/#misc_controls_orbit except I want to rotate using device orientation control.
Any idea how I can incorporate this feature?
Thank you for your assistance.
The answer to my own question for future seekers is to replace camera in
controls = new THREE.DeviceOrientationControls(camera, true);
with the 3D object you are trying to rotate.

Unity 3d show specific frame of animation

I'm trying new unity 3d options for 2d games. I'm trying to create background that changes depending on actions i made. So if i press button one i get sprite one as background and if two i get sprite two. Since I have 32 options, I figure out the best way would be to have an Animator, that changes frame depending on button click. So i created animator and animation. But the problem is I can't set time to where to stop animation to show selected frame.
I'm trying like that:
Animator ani=background.GetComponent<Animator>();
ani.animation["field_back_anim"].time=0.5f;
ani.speed=0;
But it fails at second line with that error:
MissingComponentException: There is no 'Animation' attached to the "background" game object, but a script is trying to access it.
You probably need to add a Animation to the game object "background". Or your script needs to check if the component is attached before using it.
However if I do no code the animation just plays trough all 16 frames. So i gues there is animation after all.
On the background GameObject I have 2 components first is sprite renderer and second is animator. When I open animator in Animator view i see there green rectangle saying Any state and yellow one with "field_back_anim". I don't get what i'm doing wrong.
I will also except any other solution that does the following.
Thanks!
The animator component is used to control transition between many animation clips. If you're going to playing an animation clip on a gameobject, an animation component is proper, not the animator. Remove the animator and add an animation component to your background gameobject in the inspector. If you set animation property to field_back_anim, your gameobject will animate well. Manipulation codes should be changed like below.
Animation ani = background.GetComponent<Animation>();
ani["field_back_anim"].time = 0.5f;
ani["field_back_anim"].speed = 0;

Resources