r/Unity3D – Telegram
r/Unity3D
264 subscribers
12.6K photos
15.6K videos
14 files
48K links
News about the Unity engine and project showcases from Reddit. Made possible with @reddit2telegram (@r_channels).
Download Telegram
This media is not supported in your browser
VIEW IN TELEGRAM
I released my first Asset about Insect Simulations (Free codes on Desc)

https://redd.it/1hcjgbu
@r_Unity3D
This media is not supported in your browser
VIEW IN TELEGRAM
New blink / talk animation and voice. Before or after voice? Sound on

https://redd.it/1hckfto
@r_Unity3D
Defender's Dynasty, From a Simple Tutorial to a Full-Fledged Game. First Game, a Journey Through Iterations, Refinements and Creativity!
https://redd.it/1hcn45o
@r_Unity3D
Media is too big
VIEW IN TELEGRAM
After 12 years of working solo on Zefyr, I'm getting close to release! If you like old school adventure games from the gamecube/ps2 era (Zelda Windwaker, BGE, Sly Cooper, ...) you might want to check out the demo on the Steam page! I used unity as a game engine, I think I started with 3.5!

https://redd.it/1hclvj0
@r_Unity3D
2d and 3d at the same time ?

Hello I'm new to making games
I'm inspired by inscryption and I got a idea for a game that changes from 2d to 3d but if the player moved in 3d or 2d their location would also change in both or if something happened in 2d , it also changes in 3d
So is it possible in unity ?

https://redd.it/1hcv2ph
@r_Unity3D
need help with 2d boost

im making a boost mechanic in 2d similar to sonic rush games. the boost functions fine but theres a bug where, if grounded, if unlockDash is false, if boosting off an edge; my gravity will be set low so i float off the platform edge but it will be set really high so i cant jump.

ive integrated a dash mechanic with the boost so if unlock dash is false, the boost works normally but if unlockdash is true, the dash plays followed by the boost


ik its alot of code but any help will be appreciated!






void Boost()
{
if (Input.GetButton("Dash") && !isBoosting && canBoost)
{
if (Grounded())
{
// Grounded Boost: Dash then Boost
StartCoroutine(DoBoost(true)); // Execute Boost after Dash
}
else if (!Grounded() && Input.GetButton("Dash"))
{
// Mid-air Boost: Dash then Boost (while holding dash button)
StartCoroutine(DoBoost(false)); // Execute Boost right after air dash
}
}
}

IEnumerator DoBoost(bool isGroundedBoost)
{
if (isGroundedBoost)
{
// Start Dash if grounded
int dir = pState.lookingRight ? 1 : -1; // Use facing direction to determine dash direction
rb.velocity = new Vector2(
dir dashSpeed, 0);
yield return new WaitForSeconds(dashTime);

// Boost after Dash ends if grounded
boostTimer = 0f; // Reset boost timer
isBoosting = true;
bool boostCompleted = false;

// Don't disable gravity when grounded
if (!Grounded()) // Ensure gravity is only set to 0 when not grounded (mid-air boost)
{
rb.gravityScale = 0f; // Disable gravity only during mid-air boost
}

while (boostTimer < boostDuration && Input.GetButton("Dash"))
{
boostTimer += Time.deltaTime; // Increment boost time
rb.velocity = new Vector2(boostSpeed
(pState.lookingRight ? 1 : -1), rb.velocity.y); // Apply boost velocity in the direction the player is facing
yield return null;
}

// If the full boost duration was used, start cooldown
if (boostTimer >= boostDuration)
{
boostCompleted = true;
}

// Reset after boost ends
EndBoost(boostCompleted);
}
else
{
// In mid-air, boost directly after dash if Dash button is held
if (Input.GetButton("Dash"))
{
isBoosting = true;
boostTimer = 0f;
bool boostCompleted = false;

// Dash before boosting in mid-air
int dir = pState.lookingRight ? 1 : -1; // Use facing direction to determine dash direction
rb.velocity = new Vector2(
dir dashSpeed, 0);
yield return new WaitForSeconds(dashTime);

// Boost continues
while (boostTimer < boostDuration && Input.GetButton("Dash"))
{
boostTimer += Time.deltaTime;
rb.velocity = new Vector2(boostSpeed
(pState.lookingRight ? 1 : -1), rb.velocity.y); // Apply boost velocity in the direction the player is facing
yield return null;
}

// If the full boost duration was used, start cooldown
if (boostTimer >= boostDuration)
{
boostCompleted = true;
}

// End boost after duration
EndBoost(boostCompleted);
}
}
}

// Boost logic when unlockDash is false (only boost, no dash)
IEnumerator BoostWithoutDash()
{
if (Input.GetButton("Dash") && !isBoosting && canBoost)
{
isBoosting = true;
boostTimer = 0f;
bool boostCompleted = false;

// Store the initial direction to check for flipping
float initialDirection = pState.lookingRight ? 1 : -1; // Use facing direction to store initial direction

// Boost will happen with normal gravity when unlockDash is false
while (boostTimer < boostDuration && Input.GetButton("Dash"))
{
// If the player tries to flip, end the boost
if (Mathf.Sign(xAxis) != initialDirection)
{
EndBoost(false); // If boost didn't complete, don't start cooldown
yield break;
}

boostTimer += Time.deltaTime;
rb.velocity = new Vector2(boostSpeed initialDirection, rb.velocity.y); // Apply boost in the correct direction
yield return null; // Wait for next frame
}

// If the full boost duration was used, start cooldown
if (boostTimer >= boostDuration)
{
boostCompleted = true;
}

// After boost ends, apply momentum and end boost
ApplyMomentumAfterBoost();
EndBoost(boostCompleted);
}
}

// Boost logic after dashing mid-air
IEnumerator BoostAfterDash()
{
if (Input.GetButton("Dash") && !isBoosting && canBoost && !Grounded())
{
isBoosting = true;
boostTimer = 0f;
bool boostCompleted = false;

// Store the initial direction to check for flipping
float initialDirection = pState.lookingRight ? 1 : -1; // Use facing direction to store initial direction

// Disable gravity only during the boost if you're not grounded (mid-air boost)
rb.gravityScale = 0; // Temporarily disable gravity when boosting in the air

// Apply boost horizontally during the boost
while (boostTimer < boostDuration && Input.GetButton("Dash"))
{
// If the player tries to flip, end the boost
if (Mathf.Sign(xAxis) != initialDirection)
{
EndBoost(false); // If boost didn't complete, don't start cooldown
yield break;
}

boostTimer += Time.deltaTime;
rb.velocity = new Vector2(boostSpeed
initialDirection, rb.velocity.y); // Apply boost in the correct direction
yield return null; // Wait for next frame
}

// If the full boost duration was used, start cooldown
if (boostTimer >= boostDuration)
{
boostCompleted = true;
}

// After boost ends, apply momentum and end boost
ApplyMomentumAfterBoost();
EndBoost(boostCompleted);
}
}

// Applies momentum after the boost ends
void ApplyMomentumAfterBoost()
{
// Store current velocity
float currentVelocityX = rb.velocity.x;

// Apply some momentum in the direction the player is facing, but without immediately stopping
StartCoroutine(MomentumCoroutine(currentVelocityX));
}

IEnumerator MomentumCoroutine(float initialVelocityX)
{
// Small momentum multiplier after the boost ends
float momentumMultiplier = 1.2f; // Adjust this value for desired
need help with 2d boost

im making a boost mechanic in 2d similar to sonic rush games. the boost functions fine but theres a bug where, if grounded, if unlockDash is false, if boosting off an edge; my gravity will be set low so i float off the platform edge but it will be set really high so i cant jump.

ive integrated a dash mechanic with the boost so if unlock dash is false, the boost works normally but if unlockdash is true, the dash plays followed by the boost


ik its alot of code but any help will be appreciated!






void Boost()
{
if (Input.GetButton("Dash") && !isBoosting && canBoost)
{
if (Grounded())
{
// Grounded Boost: Dash then Boost
StartCoroutine(DoBoost(true)); // Execute Boost after Dash
}
else if (!Grounded() && Input.GetButton("Dash"))
{
// Mid-air Boost: Dash then Boost (while holding dash button)
StartCoroutine(DoBoost(false)); // Execute Boost right after air dash
}
}
}

IEnumerator DoBoost(bool isGroundedBoost)
{
if (isGroundedBoost)
{
// Start Dash if grounded
int _dir = pState.lookingRight ? 1 : -1; // Use facing direction to determine dash direction
rb.velocity = new Vector2(_dir * dashSpeed, 0);
yield return new WaitForSeconds(dashTime);

// Boost after Dash ends if grounded
boostTimer = 0f; // Reset boost timer
isBoosting = true;
bool boostCompleted = false;

// Don't disable gravity when grounded
if (!Grounded()) // Ensure gravity is only set to 0 when not grounded (mid-air boost)
{
rb.gravityScale = 0f; // Disable gravity only during mid-air boost
}

while (boostTimer < boostDuration && Input.GetButton("Dash"))
{
boostTimer += Time.deltaTime; // Increment boost time
rb.velocity = new Vector2(boostSpeed * (pState.lookingRight ? 1 : -1), rb.velocity.y); // Apply boost velocity in the direction the player is facing
yield return null;
}

// If the full boost duration was used, start cooldown
if (boostTimer >= boostDuration)
{
boostCompleted = true;
}

// Reset after boost ends
EndBoost(boostCompleted);
}
else
{
// In mid-air, boost directly after dash if Dash button is held
if (Input.GetButton("Dash"))
{
isBoosting = true;
boostTimer = 0f;
bool boostCompleted = false;

// Dash before boosting in mid-air
int _dir = pState.lookingRight ? 1 : -1; // Use facing direction to determine dash direction
rb.velocity = new Vector2(_dir * dashSpeed, 0);
yield return new WaitForSeconds(dashTime);

// Boost continues
while (boostTimer < boostDuration && Input.GetButton("Dash"))
{
boostTimer += Time.deltaTime;
rb.velocity = new Vector2(boostSpeed * (pState.lookingRight ? 1 : -1), rb.velocity.y); // Apply boost velocity in the direction the player is facing
yield return null;
}

// If the full boost duration was used, start cooldown
if (boostTimer >= boostDuration)
{
boostCompleted = true;
}

// End boost after duration
EndBoost(boostCompleted);
}
}
}

// Boost logic when unlockDash is false (only boost, no dash)
IEnumerator BoostWithoutDash()
{
if (Input.GetButton("Dash") && !isBoosting && canBoost)
{
isBoosting = true;
boostTimer = 0f;
bool boostCompleted = false;

// Store the initial direction to check for flipping
float initialDirection = pState.lookingRight ? 1 : -1; // Use facing direction to store initial direction

// Boost will happen with normal gravity when unlockDash is false
while (boostTimer < boostDuration && Input.GetButton("Dash"))
{
// If the player tries to flip, end the boost
if (Mathf.Sign(xAxis) != initialDirection)
{
EndBoost(false); // If boost didn't complete, don't start cooldown
yield break;
}

boostTimer += Time.deltaTime;
rb.velocity = new Vector2(boostSpeed * initialDirection, rb.velocity.y); // Apply boost in the correct direction
yield return null; // Wait for next frame
}

// If the full boost duration was used, start cooldown
if (boostTimer >= boostDuration)
{
boostCompleted = true;
}

// After boost ends, apply momentum and end boost
ApplyMomentumAfterBoost();
EndBoost(boostCompleted);
}
}

// Boost logic after dashing mid-air
IEnumerator BoostAfterDash()
{
if (Input.GetButton("Dash") && !isBoosting && canBoost && !Grounded())
{
isBoosting = true;
boostTimer = 0f;
bool boostCompleted = false;

// Store the initial direction to check for flipping
float initialDirection = pState.lookingRight ? 1 : -1; // Use facing direction to store initial direction

// Disable gravity only during the boost if you're not grounded (mid-air boost)
rb.gravityScale = 0; // Temporarily disable gravity when boosting in the air

// Apply boost horizontally during the boost
while (boostTimer < boostDuration && Input.GetButton("Dash"))
{
// If the player tries to flip, end the boost
if (Mathf.Sign(xAxis) != initialDirection)
{
EndBoost(false); // If boost didn't complete, don't start cooldown
yield break;
}

boostTimer += Time.deltaTime;
rb.velocity = new Vector2(boostSpeed * initialDirection, rb.velocity.y); // Apply boost in the correct direction
yield return null; // Wait for next frame
}

// If the full boost duration was used, start cooldown
if (boostTimer >= boostDuration)
{
boostCompleted = true;
}

// After boost ends, apply momentum and end boost
ApplyMomentumAfterBoost();
EndBoost(boostCompleted);
}
}

// Applies momentum after the boost ends
void ApplyMomentumAfterBoost()
{
// Store current velocity
float currentVelocityX = rb.velocity.x;

// Apply some momentum in the direction the player is facing, but without immediately stopping
StartCoroutine(MomentumCoroutine(currentVelocityX));
}

IEnumerator MomentumCoroutine(float initialVelocityX)
{
// Small momentum multiplier after the boost ends
float momentumMultiplier = 1.2f; // Adjust this value for desired