Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink

You are not connected. Please login or register

Unity Ninja Unity 3D Forum » HELP » Help (General) » The Ball jump also upon the nothing

The Ball jump also upon the nothing

View previous topic View next topic Go down  Message [Page 1 of 1]

1 The Ball jump also upon the nothing on Wed Oct 15, 2014 4:35 am

Radeon


Member [Lv. 2]
Member [Lv. 2]
I want that The ball must jump only on the terrain , the ball must not jump when is not on a ground
How i can fix this ?

-------------- SCRIPT ------------------------

var jumpDelay : boolean;
var doubleJump : int = 0;
function Update()
{
if( Input.GetKeyDown(KeyCode.Space) && jumpDelay == false)
{
Jump();
}
}

function Jump()
{
if (doubleJump <= 1)
{
rigidbody.velocity.y = 10;
jumpTimer();
}
}

function jumpTimer()
{
if (Input.GetKeyDown(KeyCode.Space))
{
doubleJump ++;
}

if (doubleJump > 1)
{
doubleJump = 0;
jumpDelay = true;
yield WaitForSeconds(3);
jumpDelay = false;
}
}

View user profile

2 Re: The Ball jump also upon the nothing on Thu Oct 16, 2014 3:44 pm

DeveloperLuke


Moderator
Moderator
I have made a double jump script that you can only jump on the ground! Here
it is.....

#pragma strict
var jumpObject : Rigidbody;
var canJump : boolean;
var groundTag : String = "Ground";
var jumpHeight = 10.0;
var doublejumpHeight = 7.5;
private var doubleJump : boolean;

function OnCollisionEnter(col: Collision) {
if(col.collider.tag == groundTag) {
doubleJump = false;
canJump = true;
}
}

function OnCollisionExit(col: Collision) {
if(col.collider.tag == groundTag) {
canJump = false;
}
}

function Update () {
if(canJump == true && Input.GetKeyDown(KeyCode.Space)) {
jumpObject.velocity.y = jumpHeight;
doubleJump = true;
}
if(canJump == false && doubleJump == true && Input.GetKeyDown(KeyCode.Space)) {
jumpObject.velocity.y = doublejumpHeight;
doubleJump = false;
}
}

Your Welcome Wooden What a Face

View user profile

3 Re: The Ball jump also upon the nothing on Wed Oct 22, 2014 8:41 am

Radeon


Member [Lv. 2]
Member [Lv. 2]
wooden_sword789 wrote:I have made a double jump script that you can only jump on the ground! Here
it is.....

#pragma strict
var jumpObject : Rigidbody;
var canJump : boolean;
var groundTag : String = "Ground";
var jumpHeight = 10.0;
var doublejumpHeight = 7.5;
private var doubleJump : boolean;

function OnCollisionEnter(col: Collision) {
if(col.collider.tag == groundTag) {
doubleJump = false;
canJump = true;
}
}

function OnCollisionExit(col: Collision) {
if(col.collider.tag == groundTag) {
canJump = false;
}
}

function Update () {
if(canJump == true && Input.GetKeyDown(KeyCode.Space)) {
jumpObject.velocity.y = jumpHeight;
doubleJump = true;
}
if(canJump == false && doubleJump == true && Input.GetKeyDown(KeyCode.Space)) {
jumpObject.velocity.y = doublejumpHeight;
doubleJump = false;
}
}

Your Welcome Wooden What a Face

Thank you, But I want that the ball after the second jump must re-jump rapidly as soon as it touches the ground, I do not want that the ball, must first stabilize and then 4 seconds later you can jump, I want that the ball must jump immediately barely touched the ground



Last edited by Radeon on Mon Dec 15, 2014 12:12 pm; edited 1 time in total

View user profile

4 Re: The Ball jump also upon the nothing on Fri Nov 21, 2014 6:13 pm

DeveloperLuke


Moderator
Moderator
English please? Or I just can't really understand what you are trying to say. Sorry.

View user profile

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum