#Clamping the Speed!

1 messages · Page 1 of 1 (latest)

brazen olive
#

Any help is appreciated!

viral gorge
#

what?

viscid bluff
brazen olive
#

Now, the speed variable isn't detected.
And I've used a method to detect the speed:

`
public Vector3 prevPos;

prevPos = transform.position;

Speed = Vector3.Distance(transform.position, prevPos) / Time.deltaTime;
`

brazen olive
inland dune
#

Show us

viral gorge
#

and where is the Vector3.Distance code

brazen olive
viscid bluff
#

Show us the important part of the script

brazen olive
#

The speed variable is also written but didn't give it any value because it wasn't calculated!

viral gorge
brazen olive
#

Mathf.Clamp(Speed, ForwardSpeed, MaxForwardSpeed);

brazen olive
#

just head to the clamp fution!

viral gorge
#

so you have a bunch of Mathf.Clamp doing nothing

#

because your doing nothing with the result

#

you want Speed = Mathf.Clamp(...);

brazen olive
#

Oh...

#

So, I have to equal the speed of every Clamp line?

viral gorge
#

yes

brazen olive
#

Alright, let me test.

viral gorge
#

but im pretty sure all the clamps wont work, only the last one since it runs last

brazen olive
#

What if I make 'em all in a single function and use && between them?

viral gorge
#

you probably want
if(reversing) //clamp reversed
if(going forward) //clamp forward
and anything else you need

brazen olive
#

I removed all of them except the second and it still worked, but to make the remaining ones work needs time!

viral gorge
brazen olive
brazen olive
#

@modern vault

#

Wait for re uploading the script+error

modern vault
#

Hey look it's not in here either

#

So get in the other thread

brazen olive
#

Lol.