Problems using smoothDamp

copenhagenjazz 3 years ago updated by Christian Engler 3 years ago 5

Hi there

I am trying to replicate the following code in Bolt;

composedPosition = Vector3.SmoothDamp(transform.position, unsmoothedPosition, ref smoothComposedPosition, .1f);

How would I go about that in Bolt? It is particularly the ref smoothComposedPosition I dont really know what to do with. Is that what in Bolt' SmoothDamp node is referred to as velocity? Shall I make a graph variable and feed that to the velocity and then store it after the SmoothDamp node?

What I am basically trying to do is to have a little rigid body sphere that once it gets close to the ground it starts hovering above ground. The player can then add forces to the sphere to move it around.

Thanks in advance

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):

Couldnt find any way to edit my original post so will just elaborate a little below here :)

But as mentioned above what I basically want to achieve is a rigid body sphere that uses the movePosition node to keep the gameobject off the ground. I do this by storing two values and smoothDamp between the two to find the movePosition transform. "Current" is the current Y position and "Target" is the Y transform of where a raycast from the sphere hits the ground + desired floating height.

It kind of works currently but it jitters and doesnt work anywhere near as stable as the script I have from which the above line of code comes from.


Here is my Macro in case someone would like to check it out. Any help would be greatly appreciated!

Hi copenhagenjazz!

I don't have the time to look at your specific graph unfortunately, but I can help you understand ref parameters in Bolt:

Here, Current Velocity is a ref parameter. The value you pass in might be modified by the unit, so it is outputted again on the right.

how would you approach a ref variable in bolt ? i'm trying to get the mathf.smoothdamp working.

but its not working 

in c# i just have a velocity variable which gets referenced like this

float myalpha = Mathf.SmoothDamp(transform.eulerAngles.x, myslider.value, ref yVelocity,smooth);

i tried the same in bolt with a scene variable get and set, but no luck. any hint ?

got it working.well sort of...