Important News

We have released Shinobi Life Online Pre-Alpha Version 1.1.0.0! This update features Earth Release: Earth Dome Jutsu, Aiming Mode and more! Try it out and tell us what you think.

User

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

Discord

Statistics

Members
Total Members: 53843
Latest: Mehki
New This Month: 41
New This Week: 2
New Today: 2
Stats
Total Posts: 55991
Total Topics: 3364
Most Online Today: 349
Most Online Ever: 4232
(January 14, 2020, 07:47:33)
Users Online
Members: 0
Guests: 326
Total: 330
Google (3)
Baidu

Author Topic: Jumping script help c#  (Read 1584 times)

0 Members and 1 Guest are viewing this topic.

Offline Kakashi Natsu

  • Chunin Poster
  • ***
  • Posts: 141
  • Reputation Power: 2
  • Kakashi Natsu has no influence.
  • Gender: Male
  • Give up trying to make me give up.
    • View Profile
  • Clan: Agni
Jumping script help c#
« on: August 08, 2016, 22:05:58 »
EDITED: FIXED>> NO NEED FOR HELP.

i need help with this jumping script:
(UPDATE): I got it to work, I dont know if there is a more efficient way to script this.
Code: [Select]
void FixedUpdate(){


float straffe = Input.GetAxis ("Horizontal") * speed;
float translation = Input.GetAxis ("Vertical") * speed*multiplier;
bool attack = Input.GetKey (KeyCode.E);

Grounded ();

if (IsGrounded) {

gravity = 0;
moveDirection = new Vector3(straffe,0 , translation);
anim.SetBool ("IsGrounded", true);
canJump = true;

} else {

if (!canJump) {
gravity += 0.1f;
moveDirection = new Vector3(straffe,-gravity , translation);
anim.SetBool ("IsGrounded", false);
}
}



if (canJump) {
if (Input.GetKey (KeyCode.Space)) {
power -= 1;
if (power < 0) {
canJump = false;

}

moveDirection = moveDirection = new Vector3 (straffe, power, translation);
} else {
power = copypower;
canJump = false;

}
}
print (rbody.velocity);

rbody.velocity = moveDirection;

if (translation > 0) {
anim.SetBool ("IsWalking", true);
anim.SetBool ("IsWalkingBack", false);
anim.SetBool ("IsIdle", false);

if (Input.GetKeyDown (KeyCode.LeftShift)) {
anim.SetBool ("IsRunning", true);

multiplier = 2;

}
if (Input.GetKeyUp (KeyCode.LeftShift)) {
anim.SetBool ("IsRunning", false);
multiplier = 1;
}
}else if (translation < 0 ) {
multiplier = 1;
anim.SetBool ("IsWalkingBack", true);
anim.SetBool ("IsWalking", false);
anim.SetBool ("IsIdle", false);
anim.SetBool ("IsRunning", false);
}
else {
multiplier = 1;
anim.SetBool ("IsWalking", false);
anim.SetBool ("IsWalkingBack", false);

if (attack) {
anim.SetBool ("IsIdle", false);

} else {
anim.SetBool ("IsIdle",true);
}
}

if (straffe > 0 || straffe < 0) {
anim.SetBool ("IsWalking", true);
anim.SetBool ("IsIdle", true);

}

if (Input.GetKeyDown ("escape")) {
counter++;
}

}

void Grounded(){
RaycastHit hitInfo;
if(Physics.Raycast(transform.position + (Vector3.up * 0.1f), Vector3.down, out hitInfo, 0.1f))
{

IsGrounded = true;

}
else
{
IsGrounded = false;

}

}


there is no issues with the frames of when i press key down and when it events happens
here is the ground porgram to check if its on the ground
Code: [Select]
void Grounded(){
RaycastHit hitInfo;
if(Physics.Raycast(transform.position + (Vector3.up * 0.1f), Vector3.down, out hitInfo, 0.3f))
{

IsGrounded = true;

}
else
{
IsGrounded = false;

}

}


Thanks, if you need ANY MORE INFORMATION, JUST ASK!, no question is a stupid one. only answers have the possibility to be stupid.
« Last Edit: August 10, 2016, 02:12:34 by Kakashi Natsu »



Offline Mars

  • Hidden Hill Kage
  • Hidden Village Kage
  • Sennin Poster
  • ***
  • Posts: 2 648
  • Reputation Power: 6
  • Mars has no influence.
  • Gender: Male
    • View Profile
  • Clan: Hinode
  • Organization: YĆ¼rei
Re: Jumping script help c#
« Reply #1 on: August 09, 2016, 10:59:35 »
  • Character Name: Kuria Hinode

 

Recent Topics

Uzumaki Clan by LethalDarkness4
March 14, 2022, 23:07:32

My Computer Freezes While Playing 'Shinobi Life Online' by Jamezoar
March 13, 2022, 17:04:23

Crashed when I log in by WeebyJay
November 02, 2021, 00:38:43

The Lie That Never Lived: Shionbi Life Online by Ken
October 26, 2021, 00:28:55

OC by Hikaru_Kitetsu
September 30, 2021, 17:29:28

I suggest we can do genjutsus by NinjaMirage
September 28, 2021, 13:01:13

Hug,slap,kiss or kill - Fourm game. by MarkKlaus3
September 17, 2021, 12:59:31

Unable To Hide Online Status From Xbox! by EfrainSawayn
September 16, 2021, 07:45:04

I suggest that we can customize our character and we can belong to a clan by raruto
August 18, 2021, 22:54:15

I suggest that we can have a biju stamp like naruto and that we can become biju by raruto
August 18, 2021, 22:53:10

Top Posters

Mars
Posts: 2648
Reminance
Posts: 2246
Shivraj
Posts: 1610
m4r1us
Posts: 1298
Manuster
Posts: 1271
NinjaMirage
Posts: 1173
Nova
Posts: 1152
taigakun
Posts: 1099
Fraudulent
Posts: 1098
Konohuro
Posts: 1060