playMaker

Author Topic: How would you go about Dampening FPS arms?  (Read 3735 times)

VivaLaBaz

  • Playmaker Newbie
  • *
  • Posts: 23
How would you go about Dampening FPS arms?
« on: March 01, 2020, 07:06:23 AM »
So I currently have my FPS arms a child of the camera which obviously works but how would i go about dampening the arms a little when i move the camera?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: How would you go about Dampening FPS arms?
« Reply #1 on: March 02, 2020, 01:58:43 AM »
Hi.
You can find several 'Damp' actions on the Ecosystem
maybe one of then you can use :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15620
  • Official Playmaker Support
Re: How would you go about Dampening FPS arms?
« Reply #2 on: March 02, 2020, 06:06:25 AM »
Hi,

 basically, you make a dummy gameobject which represent the desired position and orientation maybe, then make your arm ease towards that position,  using MoveTowards and rotateTowards for example.

Bye,

 Jean

VivaLaBaz

  • Playmaker Newbie
  • *
  • Posts: 23
Re: How would you go about Dampening FPS arms?
« Reply #3 on: March 02, 2020, 12:22:51 PM »
Hi.
You can find several 'Damp' actions on the Ecosystem
maybe one of then you can use :)

I've tried these, but I couldn't seem to get the rotation working.

Hi,

 basically, you make a dummy gameobject which represent the desired position and orientation maybe, then make your arm ease towards that position,  using MoveTowards and rotateTowards for example.

Bye,

 Jean

This works, but it glitches out. The arm model wobbles when moving.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15620
  • Official Playmaker Support
Re: How would you go about Dampening FPS arms?
« Reply #4 on: March 03, 2020, 01:28:51 AM »
Hi,

Are you using Animator and the IK ?

Can you make a video showing what's happening?

Bye,

 Jean

VivaLaBaz

  • Playmaker Newbie
  • *
  • Posts: 23
Re: How would you go about Dampening FPS arms?
« Reply #5 on: March 03, 2020, 10:51:48 AM »
Hi,

Are you using Animator and the IK ?

Can you make a video showing what's happening?

Bye,

 Jean

No im not using Animator and IK as I'm not actually using arms, im using a cell phone.


Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 824
Re: How would you go about Dampening FPS arms?
« Reply #6 on: March 03, 2020, 01:18:07 PM »
You mean you use the phone's orientation?
The device's camera acts as Unity's main camera I suppose.
Are you doing some augmented reality thing?

The idea likely remains the same, since you orient the Unity camera according to the orientation of the real device.
You need to have your 3D modeled arms follow the Unity camera with a little delay, through using a lerp for example.

VivaLaBaz

  • Playmaker Newbie
  • *
  • Posts: 23
Re: How would you go about Dampening FPS arms?
« Reply #7 on: March 04, 2020, 12:12:50 AM »
You mean you use the phone's orientation?
The device's camera acts as Unity's main camera I suppose.
Are you doing some augmented reality thing?

The idea likely remains the same, since you orient the Unity camera according to the orientation of the real device.
You need to have your 3D modeled arms follow the Unity camera with a little delay, through using a lerp for example.

No that's not correct, I am not using the phones camera as the main camera.
As you can see in my video above the character is just "holding" the phone.

Is there a specific way to use a lerp? If I make the phone a child of the camera the phone will follow 1:1 with no delay.
« Last Edit: March 04, 2020, 12:14:39 AM by VivaLaBaz »

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 824
Re: How would you go about Dampening FPS arms?
« Reply #8 on: March 04, 2020, 12:50:11 PM »
You mean you use the phone's orientation?
The device's camera acts as Unity's main camera I suppose.
Are you doing some augmented reality thing?

The idea likely remains the same, since you orient the Unity camera according to the orientation of the real device.
You need to have your 3D modeled arms follow the Unity camera with a little delay, through using a lerp for example.

No that's not correct, I am not using the phones camera as the main camera.
As you can see in my video above the character is just "holding" the phone.

Is there a specific way to use a lerp? If I make the phone a child of the camera the phone will follow 1:1 with no delay.

Right, I see. You have the phone's position that jitters horribly when it should not.
Yes, making the phone a child of the camera would solve this, it would inherit both position and orientation from the camera. However, it would be extremely rigid.
I suspect the shaking being due to the calculation based on the ever changing position of the camera, essentially restarting the gradual positioning at every frame.

What actions have you used exactly? Please make a capture of them.

There are tricks, like displaying certain elements as a late update (good for graphics), and since you're doing a FPS, you could look into using a secondary camera that would only see the phone; you would need to set the culling so as to filter everything else for that camera and then project that second camera's render into a texture to project into the first camera.

There are FPS tutorials that help you set up the double camera system.

However the phone in cam 2 would still be stiff, you'll need to reuse the accelerations of cam 1 (main cam) to somehow apply some smooth slides on X and Y to your phone so it appears to be affected by inertia as you move forth and back, spin on your feet, etc.

VivaLaBaz

  • Playmaker Newbie
  • *
  • Posts: 23
Re: How would you go about Dampening FPS arms?
« Reply #9 on: March 06, 2020, 11:17:21 AM »
You mean you use the phone's orientation?
The device's camera acts as Unity's main camera I suppose.
Are you doing some augmented reality thing?

The idea likely remains the same, since you orient the Unity camera according to the orientation of the real device.
You need to have your 3D modeled arms follow the Unity camera with a little delay, through using a lerp for example.

No that's not correct, I am not using the phones camera as the main camera.
As you can see in my video above the character is just "holding" the phone.

Is there a specific way to use a lerp? If I make the phone a child of the camera the phone will follow 1:1 with no delay.

Right, I see. You have the phone's position that jitters horribly when it should not.
Yes, making the phone a child of the camera would solve this, it would inherit both position and orientation from the camera. However, it would be extremely rigid.
I suspect the shaking being due to the calculation based on the ever changing position of the camera, essentially restarting the gradual positioning at every frame.

What actions have you used exactly? Please make a capture of them.

There are tricks, like displaying certain elements as a late update (good for graphics), and since you're doing a FPS, you could look into using a secondary camera that would only see the phone; you would need to set the culling so as to filter everything else for that camera and then project that second camera's render into a texture to project into the first camera.

There are FPS tutorials that help you set up the double camera system.

However the phone in cam 2 would still be stiff, you'll need to reuse the accelerations of cam 1 (main cam) to somehow apply some smooth slides on X and Y to your phone so it appears to be affected by inertia as you move forth and back, spin on your feet, etc.

I'm unsure on which actions you wanted me to post, so
here's the character
https://ibb.co/gzt96h5

The camera
https://ibb.co/m8Bgzz6

and the phone
https://ibb.co/Rv2g8Hy

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 824
Re: How would you go about Dampening FPS arms?
« Reply #10 on: March 07, 2020, 02:18:48 PM »
Since you have this problem with both translations and rotations, have you tried ticking the option "late update" in Set Rotation, just to see what happens?

I see the actions on the phone. There's a Match Transform action on the Ecosystem, you can try it.
Here is the Github link:
https://github.com/jeanfabre/PlayMakerCustomActions_U4/blob/master/Assets/PlayMaker%20Custom%20Actions/Transform/MatchTransform.cs

Look at these tutorials too (bit long but quite useful):