Hi, just a quickie, how can I make it so that my joystick adds force, rather than just moves an object? I think it is this that I need to fiddle with. I’ve been messing around with it to no luck for a while now
(actual script)
movement *= speed * ( ( absJoyPos.x > absJoyPos.y ) ? absJoyPos.x : absJoyPos.y )
Thanks all
New code added to help -
camerarelativecontrol.js (goes on char)
Joystick.js
Thanks in advance
Wonderful, wonderful helpers
Your movement is done by a character controller at the moment => character.Move( movement );
your variable ‘movement’ is already Vector3 , so just replace at that point in the script (line 58 on your pastebin) with =>
//character.Move ( movement );
rigidbody.AddForce ( movement );
remember, the ball need a rigidbody component attached to it.
some info on rigidbody =>
http://unity3d.com/support/documentation/Components/class-Rigidbody.html
http://unity3d.com/support/documentation/ScriptReference/Rigidbody.html
hope this helps
Bicko
March 21, 2012, 11:13am
2
Rigidbody.AddForce is what you want… but I can see in your script it’s there but has been commented-out, how come?
Completely untested but I guess something like this would work, although you might need to change the Force Mode .
rigidbody.AddForce(absJoyPos.x, absJoyPos.y, 0, ForceMode);
err…
can i suggest u to download a demo called “Rolling Ball” (i think) in UNITY ASSETS…
there’s a script where the ball moves without a character controller…
except it cannot jump… (yet)
@_ ____@
its free… (at the moment…)
hope this helps u…