last day (14 days later) » 

11:36
1
A: Object movement to a circular shape, with the grab of a VR controller?

Arcane EngineerSo you want to restrict the usual spherical movement that occurs as you move the Vive controller around, to a sort of equatorial, planar movement. I'm going to assume that as in this tutorial, your Vive controllers and head are all part of the same transform hierarchy (what they call CameraRig th...

Thanks for your response but answers(option A and b) doesn't make any sense, i guess. by setting only rotation of the sphere i can only maintain its circular position as option 1 suggested. While for option B, the circle should be at head height but move able around 360 of the player using controller.
@MohammadFaizanKhan About Option A, you are correct. I have edited the answer. About Option B, this should then do what you suggest, no? Lock it to a circle whose plane is perpendicular to the up-vector of the player's body and head. I've elaborated on both, in any case.
Edited again. Hope it makes sense this time. Let me know if not.
Hi arcane engineer, thanks for your valueable input, i have red your answer 3 or 4 times it seems applicable with some limitation which i will discuss you after the implementation. currently the first option i am implementing. i will let you know its hurdles or limitation soon
@MohammadFaizanKhan OK, thanks and good luck with it.
This is your first option, Right? : 1. Make an empty game object (swivel) 2. Make a sphere object, set it as a child to swivel object with zero position 3. Map cam head position to swivel position (update) 4. Set sphere local postion 1 (so that it comes ahead of the player) 5. Set y and z euler angles of the swivel same as controller but with x euler angles = 0
11:36
@MohammadFaizanKhan Sounds roughly correct, not 100% sure about the axes in step 5 but they should be right, otherwise try swapping x and z.
Thanks arcane engineer, i tried option A, its working but with a bug that each time i grab the sphere its change its rotation which is far from controller.
additionally i want to tell you that i only provide y value swivel.localEulerAngles = new Vector3(0, transform.localEulerAngles.y, 0); to parent object(swivel) because setting z or x allowing sphere to move up and down or cross which is not required
@MohammadFaizanKhan OK super re y value. As for the other thing, "each time i grab the sphere its change its rotation which is far from controller" is not so clear to me. - Do you mean swivel changes rotation? or sphere? I thought it would not matter if the sphere changes rotation...
sorry silly me, maybe i am unable to explain the problem clearly. I mean i am rotating swivel object as above code suggested (through controller's y euler angle). but each time i grab object to rotate it, the object rotation jump at certain rotation. it not gripping (which actually rotation) precisely.
like if i try to grip the sphere it slight jump ahead (means rotate further) because i am setting swivel.localEulerAngles = new Vector3(0, transform.localEulerAngles.y, 0);
@MohammadFaizanKhan I think I understand what you are seeing. So, when you pick up this object, it should be like in real life, e.g. if I hold a pencil pointing away from me, then if I turn, the pencil is still pointing away, right? And also I am understanding that in the moment you pick up the object, yes it is held, but it is not right in front of you (or wherever the controller is pointing) but rather rotated more or less around camera y axis than the controller itself?
I don't want to rotate my sphere all the time it should rotate on controller grip. so i grip the sphere i run this code swivel.localEulerAngles = new Vector3(0, transform.localEulerAngles.y, 0);, it slight jump (means rotation set but not at that precise location). altough it is rotating in circular shape very fine, thanks for this. you alomst done it
no actually the sphere representing day cycle of my environment. it will rotate around the player as day progress. and a user will be able to rotate through controller in order to change day time. he can grip the sphere to rotate it but the ball will not leave the circular path which is almost done using your answer but the problem is that as i tried to grip sphere it get rotation from controller which make the sphere object slight away from controller but its rotating fine
11:36
"make the sphere object slight away from controller" - along the circular path? or along a line facing out from the player? And is there just this one problem?
@MohammadFaizanKhan Can you send me a small screenshot of your transform hierarchy, please? Just so I can see how things are nested there. Then I can suggest a solution. Basically though, you need to calculate and store a y-rotational offset when you grab, and either subtract or add that to the y-rotation you are setting from the controller's transform, in each Update(). This should ensure that the object stays exactly where it should be, when we start.
Yes, you almost right and offset require to add or subtract, wait i am uploading video
I wonder, maybe Option B will be easier for you... then it will also work easily if sun / moon goes overhead...
here is the link of problem youtu.be/XBO2RghgqLc
option b can be tricky (i dind't try this yet) due to fact that it will come near or far from my head.
OK I'm in chat... let me know when you're here
@MohammadFaizanKhan Come to chat, let's try to solve quickly
Aha - greetings!
11:37
welcome
Now this thing about option B...
did you check video
I did check
thanks
clear now
so do we proceed to option b?
option a looking fine
well I'm just considering. option A is still possible, but you will need to figure out the rotational offset yourself - this will be the difference between vivecontroller.transform.eulerAngles.y and sphere.transform.eulerAngles.y
(I don't know if that's vive - sphere or sphere - vive, you will have to play around to see)
but... Option B will automatically keep the right rotation
however, as you say,
then we need to prevent it from coming too close or far from the player's head?
because the vive controller can come right up to your face?
I think it's easier to solve Option B's problem. And you won't need a swivel.
exactly that why i didn't try this because this kind of work i have already done
11:41
OK, let me ask you some questions more about how this is supposed to work...
When you grab the object/sphere - you need the sphere to always stay at fixed radius, right? so if you move vive controller to your face, will the sphere stay at this fixed radius? and if you move vive controller further away, will the sphere object also still stay on fixed radius?
Second question - will you ever need to tilt the plane on which the circle sits? Or will the plane always be either around your waist or exactly overhead? i.e. plane is oriented at either 0 or 90 degrees around the z axis?
yes radius will be fixed as i want to rotate around my player and it will be at waist height as you can watch my video
OK perfect. Then with option B we just do this...
and as my controller touch the sphere and grip it will start rotating
11:46
(got it)
so with option B, the sphere must be a child of the player head camera or body (they have same xz position, so either is fine as the parent of sphere)
....at least, it must become a child when it gets touched, even if it is not usually a child of the player camera
And make sure that its local position in camera is 0,0,0
Then every frame, once you have set the X and Z (world) position of the sphere to same as vive controller, you just need to make sure that we enforce your fixed radius.
so you set sphere.transform.position.x and .z (world coordinates) to same as vive controller, then you immediately (on next line of code) look at sphere.transform.localPosition (local coordinates)
look at sphere.transform.localPosition.Magnitude. This will be the distance from the camera. We need to fix this magnitude to some radius that you have pre-defined.
one sec
so you use Vector3.ClampMagnitude to do that.
Vector3.ClampMagnitude(sphere.transform.localPosition, radius);
and you should be all systems go
my goodness i am trying to understand your last post. seems harder
so what we are doing is (1) locking sphere to the circle's general plane (xz) by setting position same as vive controller, (2) setting its height to head height by making it a child of the head camera and setting local y to 0 (same as camera), and (3) then restricting the distance from the camera to always be radius r, as if we had a fixed-length rod spinning around a shaft.
Basically ClampMagnitude is step (3). It's saying, "you can be at whatever angle you like around the camera, but you must always be exactly 1 metre away from me" (for example).
Like if you stick a nail in the ground, and you tie a string of 10 cm to it, then you put a pencil on the other end, you can draw a perfect circle if you stretch the string as far as it can go from the nail.
(Old technology :) )
1. Make a sphere and set its x and z position according to vive controller x and z position
yes - on every Update
wait let me summarize the algorithm
yes
1. Make a sphere and set its x and z position according to vive controller x and z position (on update)
2. set head as sphere parent
3. set local y position of sphere to zero or same as head y (on update)
4. then restricting the distance from the camera to always be radius r?? what is this
please first confirm the first three points
wait
say when... I must work shortly
also, you can look here: awwapp.com/b/uttloscke
...just a diagram I made showing constraining vive controller position to a circle.
About your points...
1. Make a sphere and set its x and z (WORLD) position according to vive controller (WORLD) x and z position (on update) (WORLD POS = transform.position)
2. set head as sphere parent (OK)
3. set local xyz position (transform.localPosition) of sphere to zero (Vector3.zero)
4. restrict distance to your desired distance - you decide what r is (I would start with r=1 or r=2 for testing). This is how far in front of the camera the sphere will be.
good luck, I will leave this tab open but must work now. I think you can manage it from there....
12:20
Thanks you so much for your precious time

last day (14 days later) »