Jump to content

Need Unity Master of doom.

Yali

Hey y'all

I'm currently searching a way how to do simillar player mechanics of this game: Bean Boy (

)
I'm just looking for the mechanics for the jump.

 

(I use the Unity Engine)

So.. Yeah.. clear.png
-Yali

99 Kid. Yes. A 'Youngster'.

World famous Couchpotatoe.

Link to comment
Share on other sites

Link to post
Share on other sites

It looks to be just a Simple 

RigidBody::ApplyForce()

or whatever it is. Its mostly going to applied over several frames to stop it from going wonky.

 

EDIT: This is psuedo code. Don't copy pasta.

if (key.isdown("SPACE")){Object.ApplyForceOverFrames(50, 5); // 50 units of force over 5 frames}

CPU: Intel i7 - 5820k @ 4.5GHz, Cooler: Corsair H80i, Motherboard: MSI X99S Gaming 7, RAM: Corsair Vengeance LPX 32GB DDR4 2666MHz CL16,

GPU: ASUS GTX 980 Strix, Case: Corsair 900D, PSU: Corsair AX860i 860W, Keyboard: Logitech G19, Mouse: Corsair M95, Storage: Intel 730 Series 480GB SSD, WD 1.5TB Black

Display: BenQ XL2730Z 2560x1440 144Hz

Link to comment
Share on other sites

Link to post
Share on other sites

 

It looks to be just a Simple 

RigidBody::ApplyForce()

or whatever it is. Its mostly going to applied over several frames to stop it from going wonky.

if (key.isdown("SPACE")){Object.ApplyForceOverFrames(50, 5); // 50 units of force over 5 frames}

Wow. I'll try that thx!

99 Kid. Yes. A 'Youngster'.

World famous Couchpotatoe.

Link to comment
Share on other sites

Link to post
Share on other sites

Hey y'all

I'm currently searching a way how to do simillar player mechanics of this game: Bean Boy (VideoLink)

I'm just looking for the mechanics for the jump.

 

(I use the Unity Engine)

So.. Yeah.. clear.png

-Yali

I DONT use unity but rather I made an OpenGL game engine through Java, and you need to do it as if there were physics, that is the only way to do it to make it look real.

 

 

so what you need a gravity constant (negative val), a jump (positive val or initial velocity), and each second subtract the gravity constant from the velocity.

 

so if velocity upward it +5, and the g const is -2,

after the jump it will be

 

second 1: 5

second 2: 3

second 3: 1

second 3.5: the guy is still, so 0

second 4(downward fall): -1

 

so on until the velocity is the same so the total change in position in the y direction is 0, I DONT know any unity, but if you have some way to calculate time you should be good. thats why i gave you the logic, so you see the analysis behind it

..

I think you should understand it rather than copying code.

 

 

EDIT: then -> than

PC Part Picker: https://pcpartpicker.com/b/hZCypg  ProcessorIntel Core i7 6700k ; MOBO: Gigabyte GA-Z170MX-Gaming 5RAMCorsair Dominator Platinum 16GB 2400 MHz (spray painted the top part red); GPUGTX 1070 - Gigabyte Variant (Custom painted the Cooler and Fans Red); Case: NZXT S340 (Red); PSUCX 750W  (Bronze 80+); SSD: Crucial 256GB (Boot drive and for applications) and Sandisk 480GB Extreme pro SSD and a Samsung T3 1TB External USB-C SSDHDDWD Blue 1TB, Seagate 3TB (Both Run at 7200RPM); Displays: Asus something (1080p @ 144hz) and LG 27UD68-W 4K 60Hz IPSLaptop: Dell XPS 15 9550 (i7 6700HQ, 16GB RAM, 256 SSD, GTX 960M)

 

Link to comment
Share on other sites

Link to post
Share on other sites

Wow. I'll try that thx!

From that line of code, it seems that unity has some physics/mechanics built into it, so I should probs shut up lol.

But I tried, and if you had to make a jump method, what i said would be the answer and that is the logic behind the ApplyForceOverFrames Method

PC Part Picker: https://pcpartpicker.com/b/hZCypg  ProcessorIntel Core i7 6700k ; MOBO: Gigabyte GA-Z170MX-Gaming 5RAMCorsair Dominator Platinum 16GB 2400 MHz (spray painted the top part red); GPUGTX 1070 - Gigabyte Variant (Custom painted the Cooler and Fans Red); Case: NZXT S340 (Red); PSUCX 750W  (Bronze 80+); SSD: Crucial 256GB (Boot drive and for applications) and Sandisk 480GB Extreme pro SSD and a Samsung T3 1TB External USB-C SSDHDDWD Blue 1TB, Seagate 3TB (Both Run at 7200RPM); Displays: Asus something (1080p @ 144hz) and LG 27UD68-W 4K 60Hz IPSLaptop: Dell XPS 15 9550 (i7 6700HQ, 16GB RAM, 256 SSD, GTX 960M)

 

Link to comment
Share on other sites

Link to post
Share on other sites

Wow. I'll try that thx!

Btw ur game looks sick

PC Part Picker: https://pcpartpicker.com/b/hZCypg  ProcessorIntel Core i7 6700k ; MOBO: Gigabyte GA-Z170MX-Gaming 5RAMCorsair Dominator Platinum 16GB 2400 MHz (spray painted the top part red); GPUGTX 1070 - Gigabyte Variant (Custom painted the Cooler and Fans Red); Case: NZXT S340 (Red); PSUCX 750W  (Bronze 80+); SSD: Crucial 256GB (Boot drive and for applications) and Sandisk 480GB Extreme pro SSD and a Samsung T3 1TB External USB-C SSDHDDWD Blue 1TB, Seagate 3TB (Both Run at 7200RPM); Displays: Asus something (1080p @ 144hz) and LG 27UD68-W 4K 60Hz IPSLaptop: Dell XPS 15 9550 (i7 6700HQ, 16GB RAM, 256 SSD, GTX 960M)

 

Link to comment
Share on other sites

Link to post
Share on other sites

 

It looks to be just a Simple 

RigidBody::ApplyForce()

or whatever it is. Its mostly going to applied over several frames to stop it from going wonky.

if (key.isdown("SPACE")){Object.ApplyForceOverFrames(50, 5); // 50 units of force over 5 frames}

Oh wow.

 

Btw ur game looks sick

Oh, it's not mine :D

99 Kid. Yes. A 'Youngster'.

World famous Couchpotatoe.

Link to comment
Share on other sites

Link to post
Share on other sites

I DONT use unity but rather I made an OpenGL game engine through Java, and you need to do it as if there were physics, that is the only way to do it to make it look real.

 

 

so what you need a gravity constant (negative val), a jump (positive val or initial velocity), and each second subtract the gravity constant from the velocity.

 

so if velocity upward it +5, and the g const is -2,

after the jump it will be

 

second 1: 5

second 2: 3

second 3: 1

second 3.5: the guy is still, so 0

second 4(downward fall): -1

 

so on until the velocity is the same so the total change in position in the y direction is 0, I DONT know any unity, but if you have some way to calculate time you should be good. thats why i gave you the logic, so you see the analysis behind it

..

I think you should understand it rather than copying code.

 

 

EDIT: then -> than

Dude, you're a champ. Thx so much!

99 Kid. Yes. A 'Youngster'.

World famous Couchpotatoe.

Link to comment
Share on other sites

Link to post
Share on other sites

 

It looks to be just a Simple 

RigidBody::ApplyForce()

or whatever it is. Its mostly going to applied over several frames to stop it from going wonky.

if (key.isdown("SPACE")){Object.ApplyForceOverFrames(50, 5); // 50 units of force over 5 frames}

Oh is it Js?

99 Kid. Yes. A 'Youngster'.

World famous Couchpotatoe.

Link to comment
Share on other sites

Link to post
Share on other sites

Oh is it Js?

No its non functional code. Probably should have marked it psuedo but its up to you to do the coding and not copy pasting. All you have to do is apply force in the direction that you want. Its fairly trivial.

CPU: Intel i7 - 5820k @ 4.5GHz, Cooler: Corsair H80i, Motherboard: MSI X99S Gaming 7, RAM: Corsair Vengeance LPX 32GB DDR4 2666MHz CL16,

GPU: ASUS GTX 980 Strix, Case: Corsair 900D, PSU: Corsair AX860i 860W, Keyboard: Logitech G19, Mouse: Corsair M95, Storage: Intel 730 Series 480GB SSD, WD 1.5TB Black

Display: BenQ XL2730Z 2560x1440 144Hz

Link to comment
Share on other sites

Link to post
Share on other sites

From that line of code, it seems that unity has some physics/mechanics built into it, so I should probs shut up lol.

But I tried, and if you had to make a jump method, what i said would be the answer and that is the logic behind the ApplyForceOverFrames Method

What I wrote was code that I forgot to mark as psuedo but the engine does have methods for apply force vectors. For those they can be dealt with all at once, can be done through functions that are called each frame or they can be done through fixed time updates. 

CPU: Intel i7 - 5820k @ 4.5GHz, Cooler: Corsair H80i, Motherboard: MSI X99S Gaming 7, RAM: Corsair Vengeance LPX 32GB DDR4 2666MHz CL16,

GPU: ASUS GTX 980 Strix, Case: Corsair 900D, PSU: Corsair AX860i 860W, Keyboard: Logitech G19, Mouse: Corsair M95, Storage: Intel 730 Series 480GB SSD, WD 1.5TB Black

Display: BenQ XL2730Z 2560x1440 144Hz

Link to comment
Share on other sites

Link to post
Share on other sites

 

It looks to be just a Simple 

RigidBody::ApplyForce()

or whatever it is. Its mostly going to applied over several frames to stop it from going wonky.

 

EDIT: This is psuedo code. Don't copy pasta.

if (key.isdown("SPACE")){Object.ApplyForceOverFrames(50, 5); // 50 units of force over 5 frames}

The problem with this is that if your game lags, then the jump is going to be laggy as well. If you do it time-based it would be sooo much better

PC Part Picker: https://pcpartpicker.com/b/hZCypg  ProcessorIntel Core i7 6700k ; MOBO: Gigabyte GA-Z170MX-Gaming 5RAMCorsair Dominator Platinum 16GB 2400 MHz (spray painted the top part red); GPUGTX 1070 - Gigabyte Variant (Custom painted the Cooler and Fans Red); Case: NZXT S340 (Red); PSUCX 750W  (Bronze 80+); SSD: Crucial 256GB (Boot drive and for applications) and Sandisk 480GB Extreme pro SSD and a Samsung T3 1TB External USB-C SSDHDDWD Blue 1TB, Seagate 3TB (Both Run at 7200RPM); Displays: Asus something (1080p @ 144hz) and LG 27UD68-W 4K 60Hz IPSLaptop: Dell XPS 15 9550 (i7 6700HQ, 16GB RAM, 256 SSD, GTX 960M)

 

Link to comment
Share on other sites

Link to post
Share on other sites

The problem with this is that if your game lags, then the jump is going to be laggy as well. If you do it time-based it would be sooo much better

I recognize that however for what the op is posting this is a simple and I find typically less error prone approach for very early learners of unity. He really should be using a fixed time step that's independent of rendering e.g. 60 fps for physics but that's something that's probably well beyond the op at the point where he is now (I don't believe Unity has this functionality so it would be up to the dev to implement it). 

 

Yeah just use deltaTime

That is no different the apply at x frames as delta time is derived from the time between frames so your time steps would be the same. 

CPU: Intel i7 - 5820k @ 4.5GHz, Cooler: Corsair H80i, Motherboard: MSI X99S Gaming 7, RAM: Corsair Vengeance LPX 32GB DDR4 2666MHz CL16,

GPU: ASUS GTX 980 Strix, Case: Corsair 900D, PSU: Corsair AX860i 860W, Keyboard: Logitech G19, Mouse: Corsair M95, Storage: Intel 730 Series 480GB SSD, WD 1.5TB Black

Display: BenQ XL2730Z 2560x1440 144Hz

Link to comment
Share on other sites

Link to post
Share on other sites

I recognize that however for what the op is posting this is a simple and I find typically less error prone approach for very early learners of unity. He really should be using a fixed time step that's independent of rendering e.g. 60 fps for physics but that's something that's probably well beyond the op at the point where he is now (I don't believe Unity has this functionality so it would be up to the dev to implement it). 

 

That is no different the apply at x frames as delta time is derived from the time between frames so your time steps would be the same. 

Dude, there is nanoTime in all programming languages. and that is 1*10^-9 seconds. so that times 1000000000 = 1 second, w/o lag

PC Part Picker: https://pcpartpicker.com/b/hZCypg  ProcessorIntel Core i7 6700k ; MOBO: Gigabyte GA-Z170MX-Gaming 5RAMCorsair Dominator Platinum 16GB 2400 MHz (spray painted the top part red); GPUGTX 1070 - Gigabyte Variant (Custom painted the Cooler and Fans Red); Case: NZXT S340 (Red); PSUCX 750W  (Bronze 80+); SSD: Crucial 256GB (Boot drive and for applications) and Sandisk 480GB Extreme pro SSD and a Samsung T3 1TB External USB-C SSDHDDWD Blue 1TB, Seagate 3TB (Both Run at 7200RPM); Displays: Asus something (1080p @ 144hz) and LG 27UD68-W 4K 60Hz IPSLaptop: Dell XPS 15 9550 (i7 6700HQ, 16GB RAM, 256 SSD, GTX 960M)

 

Link to comment
Share on other sites

Link to post
Share on other sites

Dude, there is nanoTime in all programming languages. and that is 1*10^-9 seconds. so that times 1000000000 = 1 second, w/o lag

That still doesn't generate a fixed time step unless you can guarantee that the engine will update x times per second because you still have to query a timer object between draw calls. It is extremely hard to guarantee a frame rate on PC due to the vast variety in hardware configurations. (console this is a bit easier because there is no variation in hardware).

CPU: Intel i7 - 5820k @ 4.5GHz, Cooler: Corsair H80i, Motherboard: MSI X99S Gaming 7, RAM: Corsair Vengeance LPX 32GB DDR4 2666MHz CL16,

GPU: ASUS GTX 980 Strix, Case: Corsair 900D, PSU: Corsair AX860i 860W, Keyboard: Logitech G19, Mouse: Corsair M95, Storage: Intel 730 Series 480GB SSD, WD 1.5TB Black

Display: BenQ XL2730Z 2560x1440 144Hz

Link to comment
Share on other sites

Link to post
Share on other sites

I recognize that however for what the op is posting this is a simple and I find typically less error prone approach for very early learners of unity. He really should be using a fixed time step that's independent of rendering e.g. 60 fps for physics but that's something that's probably well beyond the op at the point where he is now (I don't believe Unity has this functionality so it would be up to the dev to implement it). 

 

There is a function called FixedUpdate that gets called on a fixed time step for physics.

1474412270.2748842

Link to comment
Share on other sites

Link to post
Share on other sites

There is a function called FixedUpdate that gets called on a fixed time step for physics.

Okay I didn't know that. 

CPU: Intel i7 - 5820k @ 4.5GHz, Cooler: Corsair H80i, Motherboard: MSI X99S Gaming 7, RAM: Corsair Vengeance LPX 32GB DDR4 2666MHz CL16,

GPU: ASUS GTX 980 Strix, Case: Corsair 900D, PSU: Corsair AX860i 860W, Keyboard: Logitech G19, Mouse: Corsair M95, Storage: Intel 730 Series 480GB SSD, WD 1.5TB Black

Display: BenQ XL2730Z 2560x1440 144Hz

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×