VR gaze system from scratch, pointer didnt follow mobile "head" - c#

I started to make a simple VR gaze system from scratch, using Unity ARFoundation. First thing was to draw a line from my point of view to "infinity", like a pointer. I have this script running on my AR Session Origin at Update:
myLine.SetPosition(0, transform.position);
myLine.SetPosition(1, transform.position+(transform.forward*1000));
This works on editor, I have a line, and I can turn and move my session origin (my "head" with camera), it follows up.
But, when I use it on mobile... the line keeps still, doesnt turn and move with the device.
What´s wrong?

Oh well... nevermind. I solve it. I needed a reference to the arCameraManager, it holds the head-tracking information.
myLine.SetPosition(0, arCameraManager.transform.position);
myLine.SetPosition(1, arCameraManager.transform.position+arCameraManager.transform.forward*100));
o/

Related

Scaling Movement in unity VR with oculus headset

There seems to be an issue when i am using VR. The movement I make is not scaled correctly with the movement in the VR. I have to move much further in reality to go where I need to in VR. I am working on the reach with the OVRgrabbable script after finding something online that may help. I am having an issue with getting the X,Y axis to be recognized as objects. Everything else about the code seems to be ok as nothing else is underlined in red.
This image is the notif. i am getting. I am just referencing the x and y axis i think it should operate just fine
I have one suggestion, on the OVRCustomHand.prefab check the configurations on the script OVRCustomSkeleton.cs:
Make sure to check the checkboxes for Update Root Pose (only if your OVRHandPrefab is not parented to OVRCameraRig), Update Root Scale (makes the hand model size is scaled either up or down based on the user’s actual hand size), Apply Bone Translation.
This will make sure the Hand's position is referenced to your scene's global space instead of real tracking space.
Hope it works!

Maximo animation i dont want my character to move with it

I have imported some Maximo animations, but when i use them i see that the character moves with the animation. when i walk for example i want it to be done via code and not the animation. how can i do this?
my animation rig is set to Humanoid, and also to loop when it ends.
i have tried to check if i can find it in the animation window, and if i can see the changes but no result. i think its the animation itself that changes its position. so please help me find this out or help me find another software where i can create an animation without moving the player.
i am talking about walking/running animations i need a way to not move it via the animation but via my character controller script.
Pretty sure you just need to turn off root motion.
https://docs.unity3d.com/ScriptReference/Animator-applyRootMotion.html
Just pick your avatar and uncheck "Apply root motion", or you can change it via code if you prefer.

How to make dynamic shape adjustment to another shape

Hi guys i was wondering how to create a shape adjustment with two objects which specifically could be described as the independent cells, one of which is static, and the second one is dynamic and surrounded by "plasma". The movement of the active object must be controllable by the user (WSAD). Collision of the active object with the static one causes the static object to be swallen, though doesn't change it's position stays in place all the time. As the active object moves, passes the swallen object and troughts it out.
See the image below:
Player character
When it comes close enough to pink enemy it's starting to swallow it (surround by yellow thing)
Pink enemy is completely sourrounded when red circle is in the centre of both.
When it leaves enemy it takes off the yellow thing
I was wondering what is the simplest way to do it. I've been thinking about cloth, physics joints, mesh substraction (is it even possible?), some kind of animation... I don't have much time to do it. Can you show me the simplest way. Which tools and approach should i use? I'm not asking for full code or full solution only for some tips.
Tim Hunter mentioned a wonderful way, most perfect in 3D.
You can use another approach in 2D :
Inside OnCollisionEnter2D try finding hit points using Collision2D.contacts . See this reference .
Create some particle effect there.
Disable the enemy
Now play swallowing animation of the player.
At animation end, enable enemy again.
Maybe calculation is little tricky, still efficient.

Particles not appearing in Unity

I have made a smoke particle effect that I instantiate everytime the player shoots, its working but can not be seen with the background. If I delete the background it's visible, I've tried changing the ordering layer, creating a new layer and putting it above the default, but no matter what it's still below the background. Any ideas?
Assuming you are developping a 2D game, you can use the z axis to set the distance of the elements to the camera (what will be the equivalent to the order of render)
Usually in a 2D game you will have the main camera at -10 in the z axis. So moving in the inspector the backgroun to, lets say z=5 or z=10, and keeping in you particle system in z=0 should solve your problem.
Try this easy trick and let me know if you are still facing problems.
You can check the second half of this video for a better understanding
Also, if you are making a 3D game you can go to the material of the particles and make sure that render face is set to both. I just had that problem and it was annoying me. but that fixed it.

Reset/Calibrate Orientation in Oculus Rift w/ Unity

I'm using an Oculus Rift with Unity, and am attempting to allow the user to zero-out the orientation of their device when they push a key. The idea is that the camera is frozen looking in a particular direction, and when the user begins the game, whatever direction they're looking in is bound to that camera orientation. I found this forum post, but it only says to use SetOrientationOffset, but doesn't provide code.
I've tried both of the following, independent and together:
OVRDevice.ResetOrientation ();
cameraController.SetOrientationOffset (Quaternion.identity);
However, neither seems to have an effect. I've even tried passing other quaternions into SetOrientationOffset, but that seemed to have no effect.
Does anyone have a working code example?
If different quaternions make no difference then you probably have a game object set in the FollowOrientation variable. If you clear that then passing in different quaternions should have an effect. Alternatively you can rotate the thing you've set in FollowOrientation. Then you need to find the correct orientation to start in. Probably the rotation of the frozen camera is what you need.

Categories