Hi all,
I am developing a game that has a fairly simple premise, you are a ball and have to roll through a rollar coaster type setting and hit ‘enemies’ that are along the way. I am new to Unitys scripting, and was wondering if anyone can point me in the right direction in what I could do to get the ball rolling up walls and to turn upside down. Examples of the level can be seen in the Environment Progress article here http://phroztee385.blogspot.com/. Any help with what scripts to use would be greatly greatly appreciated, thankyou all
Here’s a start:
var rollForce = 2.0;
var maxSpin = 10.0;
var stickeyness = 5.0;
private var grounded = false;
private var stickPos : Vector3;
function Start ()
{
rigidbody.maxAngularVelocity = maxSpin;
}
function FixedUpdate ()
{
var verInput = Input.GetAxis ("Vertical");
var horInput = Input.GetAxis ("Horizontal");
rigidbody.AddTorque (Vector3 (verInput, 0.0, -horInput) * rollForce);
// Stick to walls
if (grounded)
{
var direction = (stickPos - transform.position).normalized;
rigidbody.AddForce (direction * stickeyness);
}
}
function OnCollisionStay (collision : Collision)
{
grounded = true;
var contact = collision.contacts [0];
stickPos = contact.point;
}
function OnCollisionExit ()
{
grounded = false;
}
@script RequireComponent (typeof Rigidbody)
Hey!
Look at my game, it’s almost the same (except my game has lousy art).
http://arongranberg.com/unity/marbles.html (wasd, arrows and mouse)
The game is only in testing mode so the marble got the wrong texture and much of the things is wrong, but overall it works fine.
PS: Your art was really nice
PPS: and “F” to go into first person mode (R to zoom)