please help me with it script
var Fspeed = 250.0;
var Tspeed = 250.0;
var jump = 250;
var gravitypull = 0;
function Start(){
Screen.lockCursor = true;
}
function FixedUpdate() {
rigidbody.AddForce (Vector3(0, gravitypull, 0));
var cameraTransform = Camera.main.transform;
// Forward vector relative to the camera along the x-z plane
var forward = cameraTransform.TransformDirection(Vector3.forward);
forward.y = 0;
forward = forward.normalized;
// Right vector relative to the camera
// Always orthogonal to the forward vector
var right = Vector3(forward.z, 0, -forward.x);
if (Input.GetKey ("r")) {
Application.LoadLevel(0);
}
if (Input.GetKey ("a")) {
rigidbody.AddTorque(forward * Tspeed * Time.deltaTime);
rigidbody.AddForce(right * -Fspeed * Time.deltaTime);
}
if (Input.GetKey("d")) {
rigidbody.AddTorque(forward * -Tspeed * Time.deltaTime);
rigidbody.AddForce(right * Fspeed * Time.deltaTime);
}
if (Input.GetKey("w")) {
rigidbody.AddTorque(right * Tspeed * Time.deltaTime);
rigidbody.AddForce(forward * Fspeed * Time.deltaTime);
}
if (Input.GetKey ("s")) {
rigidbody.AddTorque(right * -Tspeed * Time.deltaTime);
rigidbody.AddForce(forward * -Fspeed * Time.deltaTime);
}
if (Input.GetKeyDown ("space")) {
rigidbody.AddForce(0,jump,0);
}
}
but it is no realistik
it is sample http://www.wooglie.com/playgame.php?gameID=292
sorry for my english
anyone help me create roll the ball similar this http://www.wooglie.com/playgame.php?gameID=292 ?
sorry for my english
I am about to go into a meeting. I wrote something similar but without the force added. That may help you in teh long run.
http://forum.unity3d.com/threads/101461-Hamster-ball…-)?p=666617&viewfull=1#post666617
I believe my script had camera problems. They could be overcome but I did not have the time to complete it.
Thanks,I look it now!
Sorry for my english
thanks, but your script have similar problem with my script, is slow rotation of the ball when I press “w” or “up” and rotatate camera
it is my script:
var force=10;
var torque = 10;
var _IsJumping = false;
var jump = 300;
function Start(){
Screen.lockCursor = true;
}
function OnCollisionEnter(collision : Collision) {
for (var contact : ContactPoint in collision.contacts) {
_IsJumping = false;
}
}
function FixedUpdate() {
var cameraTransform = Camera.main.transform;
// Forward vector relative to the camera along the x-z plane
var forward = cameraTransform.TransformDirection(Vector3.forward);
forward = forward.normalized;
// Right vector relative to the camera
// Always orthogonal to the forward vector
var right = Vector3(forward.z, 0, -forward.x);
var TorqueRight = Vector3(forward.x, 0, forward.z);
if (Input.GetKeyDown ("r")) {
Application.LoadLevel(0);
}
if (Input.GetKey ("a") !_IsJumping || Input.GetKey ("left") !_IsJumping) {
rigidbody.AddForce(right * -force, ForceMode.Acceleration);
}
if (Input.GetKey ("a") || Input.GetKey ("left")) {
rigidbody.AddTorque(TorqueRight * torque);
}
if (Input.GetKey("d") !_IsJumping || Input.GetKey("right") !_IsJumping) {
rigidbody.AddForce(right * force, ForceMode.Acceleration);
}
if (Input.GetKey("d") || Input.GetKey("right")) {
rigidbody.AddTorque(TorqueRight * -torque);
}
if (Input.GetKey("w") !_IsJumping || Input.GetKey("up") !_IsJumping) {
rigidbody.AddForce(forward * force, ForceMode.Acceleration);
}
if (Input.GetKey("w") || Input.GetKey("up")) {
rigidbody.AddTorque(right * torque);
}
if (Input.GetKey ("s") !_IsJumping || Input.GetKey ("down") !_IsJumping) {
rigidbody.AddForce(forward * -force, ForceMode.Acceleration);
}
if (Input.GetKey ("s") || Input.GetKey ("down")) {
rigidbody.AddTorque(right * -torque);
}
if (Input.GetKey ("space") !_IsJumping) {
_IsJumping = true;
rigidbody.AddForce(0,jump,0);
}
}
Ramp up the torque. If you specifically want forward faster, multiply it.
rigidbody.AddForce(forward * force * 10.0, ForceMode.Acceleration);
Other than that just change your torque or force to something bigger.
It doesn’t help.
I mean - if you do not use “a” and “d” and manage interpretation “w” and “s” and turn the camera - the ball does not have time to change direction.
The fact that I use a low rate of acceleration and rotation.
I reconfigured physics.
I have Max Angular Velocity = 100;
But I have slow rotates when use w or up and camera and don’t use a,d or left,right
If i use high addforce and addtorque a ball no roll it slides and it’s drags on the surface
sorry for my poor english