playMaker

Author Topic: How to add some kind of damping to a Vector3 value ?[SOLVED]  (Read 3594 times)

Bobyteal

  • Playmaker Newbie
  • *
  • Posts: 30
How to add some kind of damping to a Vector3 value ?[SOLVED]
« on: August 04, 2017, 12:03:28 PM »
Hi,

I have a vector3 value based on my mouse mouvement which is used as the vector3 for the Inverse Kinematic on my character ('Set Animator Look At' action).
My problem is that the value changes so fast it looks ridiculous when you are moving your mouse around. Any correct way to add a damping somewhere in the process ?

Thanks !
« Last Edit: August 15, 2017, 03:49:29 AM by jeanfabre »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How to add some kind of damping to a Vector3 value ?
« Reply #1 on: August 04, 2017, 12:22:11 PM »
Hi,
So you want the action work the same as "Smooth look At" but for the animator.

I never used this yet, if you can show me in a video how to set this up i can see if i can make an action for it to move smoothly.

Bobyteal

  • Playmaker Newbie
  • *
  • Posts: 30
Re: How to add some kind of damping to a Vector3 value ?
« Reply #2 on: August 04, 2017, 01:15:09 PM »
Hmm I can't code though, so I don't know what to show to you exactly if I do a video  :-[
Or maybe you had something else in mind ? Just tell me I will try my best.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How to add some kind of damping to a Vector3 value ?
« Reply #3 on: August 05, 2017, 10:57:53 AM »
Hi,
I mean what you are using now with the 'Set Animator Look At'

I can see several weights for body / head / eyes but i don't know what to do with them :)

Bobyteal

  • Playmaker Newbie
  • *
  • Posts: 30
Re: How to add some kind of damping to a Vector3 value ?
« Reply #4 on: August 05, 2017, 12:46:10 PM »
Oh ok, I use every parameters available on the "Set Animator Look At" and what I am using to feed the vector is 'Get Mouse Position Advanced'.
My problem is that the vector3 I am feeding to this action is instantly interpreted which makes the IK very abrupt and unnatural. I wish I could add some kind of dampening to it so it will react more progressively.
Just like for example the action "Set Animator Float" works, it gots a parameter called 'Damp time' at the bottom. :)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How to add some kind of damping to a Vector3 value ?
« Reply #5 on: August 09, 2017, 04:20:57 AM »
Hi, in the unity code there is nothing to set this smoothly directly.

maybe you could use smooth look at and use the value to set the animator.

Bobyteal

  • Playmaker Newbie
  • *
  • Posts: 30
Re: How to add some kind of damping to a Vector3 value ?
« Reply #6 on: August 10, 2017, 03:34:02 AM »
This one can't do the trick ? I found it by luck
https://docs.unity3d.com/ScriptReference/Vector3.SmoothDamp.html

Really need this  :-X
« Last Edit: August 10, 2017, 03:52:43 AM by Bobyteal »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How to add some kind of damping to a Vector3 value ?
« Reply #7 on: August 10, 2017, 07:16:40 AM »
Hi,
I recently made an action for someone that has sort of damping,
I added a rotate result to it.

you can get it on the attachment below.

Feed the vector to the Attached Action.
Then, Get The 'Rotate Result' in a variable.
Then, use that variable in the 'Set Animator Look At'

Bobyteal

  • Playmaker Newbie
  • *
  • Posts: 30
Re: How to add some kind of damping to a Vector3 value ?
« Reply #8 on: August 11, 2017, 03:09:20 AM »
When I use this action "SmoothLookAtDamped" it breaks anything before I have the opportunity to see any dampening.

My parameters : http://imgur.com/a/qIkIF

Edit : It's because the rotate result for "SmoothLookAtDamped" is normalized when IK need a full vector3 position to work.
« Last Edit: August 11, 2017, 03:20:52 AM by Bobyteal »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How to add some kind of damping to a Vector3 value ?
« Reply #9 on: August 11, 2017, 11:52:41 AM »
Hi,
Actually it did not break, but there is no object selected.
it needs to be use owner or a specified Game Object
if  set to specified Game Object and there is no Game object or a variable
it will turn red to warn you.

but i realize that you can't use this with that animator action.
as the action will turn the object self.

But good news, there are several damping actions on the way (a Vector3 damp included).

I will let you know when they are available.

Bobyteal

  • Playmaker Newbie
  • *
  • Posts: 30
Re: How to add some kind of damping to a Vector3 value ?
« Reply #10 on: August 13, 2017, 01:25:13 PM »
Thank you, you are the man, can't wait !  :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to add some kind of damping to a Vector3 value ?
« Reply #11 on: August 15, 2017, 03:49:14 AM »
Hi,

 A new SmoothDamp series of actions available on the Ecosystem now.



 Bye,

 Jean