playMaker

Author Topic: Rotate joint within a define range [SOLVED]  (Read 8916 times)

sopothetocho

  • Playmaker Newbie
  • *
  • Posts: 10
Rotate joint within a define range [SOLVED]
« on: January 08, 2013, 06:01:17 PM »
Hello
<EDIT>
Quote
Im triying to rotate the main character spine with the camera so his back is always in camera.
Im doing the following: Get rotation (main camera rotation stored as float variables), Clamp Float, rotation (spine bone).

The thing is I need to invert the values (from positive to negative) because the main character is looking at the camera when I walk.
<EDIT>
Ok I edited the post because I found the problem (I think), theres no negative values in rotation (what a stupid idea lol) what I need to do is limit rotation to a definite range, I mean rotate the joint within 350-0-90 but do not rotate from 91-349, obviously this cant not be done with Float Clamp.

Any Idea?
« Last Edit: January 10, 2013, 08:56:31 PM by sopothetocho »

Justin

  • Junior Playmaker
  • **
  • Posts: 58
Re: Rotate joint within a define range
« Reply #1 on: January 09, 2013, 02:45:48 AM »
So if I understand you correctly, you want to establish a 3rd person camera, where the players back is always facing the camera?


sopothetocho

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Rotate joint within a define range
« Reply #2 on: January 09, 2013, 03:41:15 AM »
So if I understand you correctly, you want to establish a 3rd person camera, where the players back is always facing the camera?



I already have a camera what I want to do is fix the aiming, so the character's spine dont rotate 360º only from 270º to 0º and from 0º to 90º

I have attached a picture with the idea of what I want and other with the problem.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Rotate joint within a define range
« Reply #3 on: January 09, 2013, 02:47:45 PM »
Hi,

 I am not too sure myself what you actually want. Do you have a game example or video of an existing game that could show what you are looking for?

 Because, really, I think that the default package of Unity provides this already with smooth camera follow and the likes.

bye,

 Jean

sopothetocho

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Rotate joint within a define range
« Reply #4 on: January 09, 2013, 03:45:41 PM »
Hi,

 I am not too sure myself what you actually want. Do you have a game example or video of an existing game that could show what you are looking for?

 Because, really, I think that the default package of Unity provides this already with smooth camera follow and the likes.

bye,

 Jean
Take a look at the first image I attached in my second post, thats the problem right there because I dont think the character's feet should be pointing backwards.

Justin

  • Junior Playmaker
  • **
  • Posts: 58
Re: Rotate joint within a define range
« Reply #5 on: January 10, 2013, 03:20:03 AM »
Is it your intention for the characters torso to move independently of there hips/legs?  If not, this could be an issue with the rig of the 3d model you are using as your character, or perhaps you should assign the movement/rotation/look at script to the entire character and not just a single bone or group of bones.  

If it is your intention for the characters torso to move within reason independently (and I assume it is) then perhaps you could look into float clamping a sample curve at a right angle? Or perhaps parenting invisible colliders at the appropriate angle of your choosing to the character that prevent them from rotating too far? (edit: these colliders could also be triggers that que the legs to start rotating in the appropriate direction.) These are just guesses and I have not tested them so I have no idea if they will work.  Sorry I can't be of more help.  Good luck.
« Last Edit: January 10, 2013, 03:25:49 AM by Xensamurai »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Rotate joint within a define range
« Reply #6 on: January 10, 2013, 03:25:19 AM »
Hi,

 uhm, as I understand it, the player is still within the range you want from the pic you have on your post. There may be a vocabulary issue here. The feet looks good compare to the general pose,

 what you would like to be more behind the player then on its side right? so actuall not having a 180 range of freedom for the camera, but less, am I correct?


bye,

 Jean

sopothetocho

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Rotate joint within a define range
« Reply #7 on: January 10, 2013, 04:40:49 AM »
Hi,

 uhm, as I understand it, the player is still within the range you want from the pic you have on your post. There may be a vocabulary issue here. The feet looks good compare to the general pose,

 what you would like to be more behind the player then on its side right? so actuall not having a 180 range of freedom for the camera, but less, am I correct?


bye,

 Jean

In the picture I moved the camera for you to see, the camera its fine and the feet are in the correct position but the upper boddy its not. Im talking about the rotation of the upper body (spine bone) I want to it to stop rotatin 360º

Basicaly what i want is something like this:

Like Xensamurai says I may have to rotate the legs.


Sorry english its not my first language and sometimes I dont express myself properly.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Rotate joint within a define range
« Reply #8 on: January 10, 2013, 05:22:16 AM »
Hi,

 I see, then yes, what you will need to do is a account that it's an angle and do some math before clamping.

 if angle is more than 270, then it's your "negative angle, and you should limit it using by its minimum ( never less than 300 for example, and for angle less than 90, limit using max, so that it's never more than 30, which will give a 120 degree of rotation in total, which I think is good for a spine.

does that make sense?

bye,

 Jean

sopothetocho

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Rotate joint within a define range
« Reply #9 on: January 10, 2013, 07:16:01 AM »
Hi,

 I see, then yes, what you will need to do is a account that it's an angle and do some math before clamping.

 if angle is more than 270, then it's your "negative angle, and you should limit it using by its minimum ( never less than 300 for example, and for angle less than 90, limit using max, so that it's never more than 30, which will give a 120 degree of rotation in total, which I think is good for a spine.

does that make sense?

bye,

 Jean

In theory that should work but it actually doesnt, that was one of the first things I did, actualy I dont think you can have negative values with angles, its always from 0 to 360 so if you put -300 in the min value you will always end up with 0 as a min. So if you put -300 in min and 90 in max you are only able to rotate from 0 to 90.

sopothetocho

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Rotate joint within a define range
« Reply #10 on: January 10, 2013, 11:55:15 AM »
By the way I tried different solutions, one of them involved "Get axis (Mouse X and Y)-> Rotation" and it seemed to work but the model jiggles a lot (it looks like its having a seizure) like every frame it tries to go back to its original position and also the Z axis is inverted.

Also I would like to know the differences between Set Rotation and Rotate.
« Last Edit: January 10, 2013, 12:59:58 PM by sopothetocho »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Rotate joint within a define range
« Reply #11 on: January 10, 2013, 01:56:53 PM »
Hi,

 for angles, you will find that you always have to have a middle man to handle these negative values, so it is definitly possible to use negative angle values, that you then transform back into 0-360 range, the same apply for angles greater than 360, you have to accomodate for this sometimes, unless you are a quaternion guru ( which you can count on your fingers in the worldwide community of developers...), I have seen amazing peices of code that just do incredibly complex things in few lines ( where it takes me a whole framework to achieve... d'oh). So Yes, you need to fiddle around a lot for this.

"Set rotation" defines the absolute rotation of the transform, so if everyframe you "set rotation" to 0,10,0, the transform will not rotate over time, it will simply stay at 0,10,0. NOW, "rotate" will increment your value to the existing rotation, so if everyframe you "rotate" by 0,10,0 then you will animate the transform and will rotate by 10° every frame .

 does that make sense?

bye,

 Jean

sopothetocho

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Rotate joint within a define range
« Reply #12 on: January 10, 2013, 02:08:19 PM »
Hi,

 for angles, you will find that you always have to have a middle man to handle these negative values, so it is definitly possible to use negative angle values, that you then transform back into 0-360 range, the same apply for angles greater than 360, you have to accomodate for this sometimes, unless you are a quaternion guru ( which you can count on your fingers in the worldwide community of developers...), I have seen amazing peices of code that just do incredibly complex things in few lines ( where it takes me a whole framework to achieve... d'oh). So Yes, you need to fiddle around a lot for this.

"Set rotation" defines the absolute rotation of the transform, so if everyframe you "set rotation" to 0,10,0, the transform will not rotate over time, it will simply stay at 0,10,0. NOW, "rotate" will increment your value to the existing rotation, so if everyframe you "rotate" by 0,10,0 then you will animate the transform and will rotate by 10° every frame .

 does that make sense?

bye,

 Jean

Ok I see

How can make this thing work, Get axis->rotate kinda works (works in the sense that it doesnt rotate 360º) its not exactly what I wanted but the seizure thing makes it unplayable and also the Z axis its inverted, any idea how can I fix this?.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Rotate joint within a define range
« Reply #13 on: January 10, 2013, 02:11:11 PM »
Hi,

 Would you have a package for me to look at, else it's going to be difficult without more info on what exactly you are doing currently.

bye,

 Jean

sopothetocho

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Rotate joint within a define range
« Reply #14 on: January 10, 2013, 02:16:24 PM »
Hi,

 Would you have a package for me to look at, else it's going to be difficult without more info on what exactly you are doing currently.

bye,

 Jean

Im sorry I cant do that, I have a 3G connection theres no broadband where I live. I can post pictures tell me what do you want to see and I will post it here.
« Last Edit: January 10, 2013, 02:20:54 PM by sopothetocho »