Stack Ball 3D - Made with Unity

Add to
My games
Add to
Wishlist
Save to
Collection
No reviews
Exceptional
Meh
Skip

About

the dir is calculated by:

Vector3 dir = (Vector3.up * 1.5f + subDir).normalized;

First, the up direction is the basic direction, the shattered part will fly up.

Then the subDir is left or right based on the shattered part’s position relative to the center of the stack.

Game Control

User input handling:

Detect if is pressing the screen, if so then meaning the ball should be smashing down.

if (Input.GetMouseButtonDown(0))

smash = true;

if (Input.GetMouseButtonUp(0))

smash = false;

In regards to detecting input, don’t put code in FixedUpdate, you may risk missing the user input event.

Next we will implement the ball smashing down logic.

In FixedUpdate(), when smash is true, we set the rigidbody’s velocity on the negative y axis to make it go down at a speed.

rb.velocity = new Vector3(0, -100 * Time.fixedDeltaTime * 7, 0);

Invincible mode charging

currentTime represents the progress of charging to invincible mode.

currentTime will be the variable that increments and decrements between 0 and 1.

if (smash) // if smashing, reward the player with increment of currentTime which represents the progress of charging to invincible mode

currentTime += Time.deltaTime * .8f;

else // if not smashing, the progress will go down, but 0.5f is slower thant 0.8f

currentTime -= Time.deltaTime * .5f;

Invincible mode counting down

if (invincible)

{

currentTime -= Time.deltaTime * .35f; // counting down 35% every second.

if (!fireEffect.activeInHierarchy)

fireEffect.SetActive(true);

}

if (currentTime <= 0)

{

currentTime = 0;

invincible = false; // when currentTime decreased to 0, invincible ends.

invincibleFill.color = Color.white;

}

Invincible progress UI

The type of the image is Filled which make the effect of progress bar.

Polish

Always has visual effects even idle is vital to hyper casual games.

How to make the Splash Effect when the ball hit the stack.

In Player.cs

GameObject splash = Instantiate(splashEffect);

splash.transform.SetParent(target.transform); // stays on the stack later on

we set the stack which the ball hits as the splash’s parent, then later on, the splash will stay where it is and rotate with the stack.

splash.transform.position = new Vector3(transform.position.x, transform.position.y - 0.22f, transform.position.z);

here transform.position is the global position of the ball.

Platforms
Release date
Developer
Max Mario
Age rating
Not rated

System requirements for Web

Read more...
Stack Ball 3D - Made with Unity screenshot, image №3371377 - RAWG
Edit the game info
Last Modified: May 13, 2022

Where to buy

itch.io