Player Control. Roller Ball with Cube Acceleration.

Roller Ball with Cube Acceleration.

I am having a difficult time solving this player control movement. I am new to scripting and although I feel like what I am trying to achieve is very simple, it has proven difficult for me. I am hoping the community can help out.

I am using the RollerBall scripts (Ball.cs and BallUserControl.cs) from the “Import Characters Package”. I have a cube placed on the top of the ball that currently does not spin when the ball moves left and right. I was able to achieve this with a script I am calling (Hat.cs). This is behavior is great but now I want to expand on this. I would like the ball and cube to feel like they are accelerating by rotating them together by 10 to 45 degrees counter to the rotation of the spin and player movement.

I have attached a .txt file with the 3 scripts I am using. [86537-roller-ball-with-cube-acceleration-scripts.txt|86537]

Thank you for your help

You want to use Animator Controllers for this kind of stuff.

Simply add an Animator Component to your object, then add a new Animator Controller to it.

Add an animation with just one keyframe with your object fully led back, and one with no keyframe.

Add a Float parameter “speed” to the Animator Controller.

Then, create a Blend Tree using those two animations, using the “speed” parameter to blend between the two.

Then in your script, set the float using animator.SetFloat () to the current speed.

You’re done!