r/Unity3D – Telegram
r/Unity3D
263 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
StartCoroutine(SlamFall());
}
}

IEnumerator SlamFall()
{
yield return new WaitForSeconds(0.23f);
if (slam && !slamCancel)
{
playerRb.gravityScale = 5f;
}
}

IEnumerator SlamFallAnimationEnd()
{
yield return new WaitForSeconds(0.02f);
if (isGrounded())
{
playerAnim.SetBool("SlamBlast", false);
blasted = false;
}
}

private void DancePerformed(InputAction.CallbackContext context)
{
if (!dash1 && isGrounded() && !bumped)
{
dance = true;
danceParticle.Play();
}
}

private void DanceCanceled(InputAction.CallbackContext context)
{
dance = false;
danceAir = false;
danceParticle.Stop();
}

private void CrouchPerformed(InputAction.CallbackContext context)
{
if (isGrounded() && !dance && !bumped)
{
crouching = true;
spin = false;
playerAnim.SetBool("Crouch", true);
playerAnim.SetBool("Spin", false);
}

if (!slam && playerRb.velocity.x > 0 && crouching && dash1 && !bumped)
{
transform.Translate(Vector2.right * moveSpeed * Time.deltaTime);
rolling = true;
}

else if (!slam && playerRb.velocity.x < 0 && crouching && dash1)
{
transform.Translate(Vector2.left * moveSpeed * Time.deltaTime);
rolling = true;
}

if(!isGrounded() && !dance && !slam && !blasted)
{
playerRb.velocity = new Vector2(playerRb.velocity.x, -13f);
spinDive = true;
isDashing = false;
playerAnim.SetBool("SpinDive", true);
}
}

private void CrouchCanceled(InputAction.CallbackContext context)
{
crouching = false;

if (!slam && playerRb.velocity.x > 0 && dash1)
{
rolling = false;
}
else if (!slam && playerRb.velocity.x < 0 && dash1)
{
rolling = false;
}
}

void Crouch(bool crouchFlag)
{
if (!crouchFlag)
{
if (Physics2D.OverlapCircle(ceilingCheck.position, aboveCheckRadius, ceilingLayer))
{
crouchFlag = true;
}
}

if (!crouchFlag)
{
playerAnim.SetBool("Crouch", false);
rolling = false;
}
else
{
playerAnim.SetBool("Crouch", true);
}

standingCollider.enabled = !crouchFlag;

crouchingCollider.enabled = crouchFlag;

if (Physics2D.OverlapCircle(ceilingCheck.position, aboveCheckRadius, ceilingLayer))
{
ceilingAbove = true;
}
else if (!Physics2D.OverlapCircle(ceilingCheck.position, aboveCheckRadius, ceilingLayer))
{
StartCoroutine(AboveCheckStop());
}
}

IEnumerator AboveCheckStop()
{
yield return new WaitForSeconds(0.1f);
ceilingAbove = false;
}

private void DiveDeceleration()
{
if (moveSpeed > minSpeed)
{
moveSpeed -= decelerationFactor;
}
else
{
moveSpeed = 0;
dive = false;
}
}

private void SpinPerformed(InputAction.CallbackContext context)
{
if (!spin && !dive && !crouching && !slam && !slamCancel && canWallBounce && !dance && !bumped && !wallWalk && isGrounded())
{
spin = true;
dash1 = true;
playerAnim.SetBool("Spin", true);
StartCoroutine(SpinCancel());
}

if(!isGrounded() && !spin && !dive && !crouching && !slamCancel && !dance && !bumped && !blasted && !wallWalk && canDash)
{
if (slam)
{
playerAnim.SetBool("Slam", false);
slam = false;
playerRb.gravityScale = 3;
}
playerAnim.SetBool("Dash", true);
playerAnim.SetBool("SpinDive", false);
StartCoroutine(Dash());
}
}

IEnumerator SpinCancel()
{
yield return new WaitForSeconds(0.5f);
playerAnim.SetBool("Spin", false);
spin = false;
}

#region DASHSTUFF
IEnumerator Dash()
{
canDash = false;
spinDive = false;
isDashing = true;
canDiveBomb = true;
StartCoroutine(DiveBomb());

Vector2 originalVelocity = playerRb.velocity;

if (!facingLeft && !dash1 && !dash2 && !dash3 && !dash4)
{
playerRb.velocity = new Vector2(transform.localScale.x * 19, 7f);
}
else if (facingLeft && !dash1 && !dash2 && !dash3 && !dash4)
{
playerRb.velocity = new Vector2(transform.localScale.x * -19, 7f);
}
else if (!facingLeft && dash1 && !dash2 && !dash3 && !dash4)
{
playerRb.velocity = new Vector2(transform.localScale.x * 21, 7f);
}
else if (facingLeft && dash1 && !dash2 && !dash3 && !dash4)
{
playerRb.velocity = new Vector2(transform.localScale.x * -21, 7f);
}
else if (!facingLeft && dash1 && dash2 && !dash3 && !dash4)
{
playerRb.velocity = new Vector2(transform.localScale.x * 25, 7f);
}
else if (facingLeft && dash1 && dash2 && !dash3 && !dash4)
{
playerRb.velocity = new Vector2(transform.localScale.x * -25, 7f);
}
else if (!facingLeft && dash1 && dash2 && dash3 && !dash4)
{
playerRb.velocity = new Vector2(transform.localScale.x * 28, 7f);
}
else if (facingLeft && dash1 && dash2 && dash3 && !dash4)
{
playerRb.velocity = new Vector2(transform.localScale.x * -28, 7f);
}
else if (!facingLeft && dash1 && dash2 && dash3 && dash4)
{
playerRb.velocity = new Vector2(transform.localScale.x * 31, 7f);
}
else if (facingLeft && dash1 && dash2 && dash3 && dash4)
{
playerRb.velocity = new Vector2(transform.localScale.x * -31, 7f);
}

yield return new WaitForSeconds(dashingTime);
isDashing = false;

if (!isGrounded() && !slam && !slamCancel && !diveBombed && !spinDive)
{
float timeElapsed = 0f;
float slowdownDuration = 0.3f;
float startXVelocity = playerRb.velocity.x;

while (timeElapsed < slowdownDuration)
{
playerRb.velocity = new Vector2(Mathf.Lerp(startXVelocity, originalVelocity.x, timeElapsed / slowdownDuration), playerRb.velocity.y);
timeElapsed += Time.deltaTime;
yield return null;
}

playerRb.velocity = new Vector2(originalVelocity.x, playerRb.velocity.y);
}
else if(isGrounded() && isDashing)
{
isDashing = false;
}
}

IEnumerator DiveBomb()
{
yield return new WaitForSeconds(0.4f);
canDiveBomb = false;
}
#endregion
private void
BrakePerformed(InputAction.CallbackContext context)
{
if (playerRb.velocity.x > 0 && !isBraking && !dive && !crouching && !dance && isGrounded() && !bumped && !wallWalk)
{
isBraking = true;
dash1 = false;
playerAnim.SetBool("Brake", true);
}
else if (playerRb.velocity.x < 0 && !isBraking && !dive && !crouching && !dance && isGrounded() && !bumped && !wallWalk)
{
isBraking = true;
dash1 = false;
playerAnim.SetBool("Brake", true);
}
}

private void Dash1Deceleration()
{
if (moveSpeed > 0)
{
moveSpeed -= decelerationFactor * 25f * Time.deltaTime; // Decrease speed gradually
moveSpeed = Mathf.Max(moveSpeed, 0); // Clamp speed
}
else
{
moveSpeed = 0;
isBraking = false;
dash1 = false;
dash2 = false;
dash3 = false;
dash4 = false;
playerAnim.SetBool("Brake", false);
}
}
#endregion

private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Wall") && !isGrounded() && canWallBounce && !slam && dash1 && !bumped)
{
playerRb.velocity = new Vector2(0f, 18f);
canWallBounce = false;
dive = false;
canJump = false;
freeMove = true;
}

if (collision.gameObject.CompareTag("Wall") && dash1 && isGrounded() && canJump && !ceilingAbove || collision.gameObject.layer == 6 && dash1 && isGrounded() && canJump && !ceilingAbove)
{
moveSpeed = 0;
bumped = true;
crouching = false;
playerAnim.SetBool("Bump", true);
StartCoroutine(WallDeceleration());
}

if(collision.gameObject.CompareTag("Wall") && !dash1 && isGrounded() && !ceilingAbove || collision.gameObject.layer == 6 && !dash1 && isGrounded() && !ceilingAbove)
{
wallWalk = true;
isBraking = false;
playerAnim.SetBool("Brake", false);
}
}

private void OnCollisionExit2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Wall") && !bumped && isGrounded() || collision.gameObject.layer == 6 && !bumped && isGrounded())
{
wallWalk = false;
}
}

IEnumerator WallDeceleration()
{
yield return new WaitForSeconds(0.40f);
moveSpeed = 7;
dash1 = false;
dash2 = false;
dash3 = false;
dash4 = false;
bumped = false;
playerAnim.SetBool("Bump", false);
}

https://redd.it/1i11lf8
@r_Unity3D
Put a slow down enemy movement feature

Does any know how or a video on how to add a game object that slows down the enemy speed only for a moment?

https://redd.it/1i13tff
@r_Unity3D
Unity 6 – ready to use, or too early. Discuss?

Has anyone upgraded to Unity 6? If so, have you had any issues? Have you explored features like the UI Toolkit, Unity Sentis, or the new lighting? I started learning on a previous version of Unity and am now trying to decide which version to use when I begin prototyping my games.

https://redd.it/1i1555g
@r_Unity3D
How to Create a Shader for Stretching a 2D Sprite Based on Cursor or Touch Movement?

Hi everyone,

I’m trying to create a shader for a 2D Sprite Renderer that stretches the sprite based on the direction of mouse cursor movement or touch gestures on the screen.

Here’s the functionality I’m aiming for:

When the user interacts with the sprite by touching or clicking within its collider (e.g., at point A (1, 0, 0)) and moves their hand or cursor to point B (3, 0, 0), the sprite should stretch in the direction of vector AB.
This stretching behavior should work for any direction in which the user moves their gesture.

I have some experience with creating shaders, but my attempts so far haven’t produced the desired results.

If anyone has encountered a similar problem, I would greatly appreciate your help. Specifically, if you could share guidance, examples, or keywords I can use to research this further, it would be really helpful.

Thank you in advance!

https://preview.redd.it/7v6gmm6mozce1.png?width=1920&format=png&auto=webp&s=5045df7ab814a1c0b749f387732c1430443a2267



https://redd.it/1i1agtr
@r_Unity3D
Duplicating a prefab but the animation stays for all

I’ve duplicated a prefab but want to change the animation state attached to each individually. How? Is it possible?

https://redd.it/1i1d6l9
@r_Unity3D
This media is not supported in your browser
VIEW IN TELEGRAM
Trying to find visual identity for my weird horror game, really digging this look

https://redd.it/1i1895s
@r_Unity3D
I humbly come to ask a silly question, but is there a way to do this without so many transitions?

NOTE: I didn't finish it.
https://redd.it/1i172e8
@r_Unity3D
This media is not supported in your browser
VIEW IN TELEGRAM
At some point I lost track of all the now unused placeholder assets I made when prototyping my game... So I proceeded to blatantly reinvent the wheel and came up with a Python noscript to track them down. If there's enough interest, I'll put it up on Github.
https://redd.it/1i1b2re
@r_Unity3D
It's been 1 year since I released the demo, finally hit 14k wishlists. It has been tough.
https://redd.it/1i1h54r
@r_Unity3D
This media is not supported in your browser
VIEW IN TELEGRAM
Hello! I'm experimenting particle sytem! Which effect do you prefer for custom fireworks??? 🎆

https://redd.it/1i1h8l9
@r_Unity3D
This media is not supported in your browser
VIEW IN TELEGRAM
My First Steam Game "Gigacrab" Is Almost Ready! Looking for Honest Feedback 🙌

https://redd.it/1i19h2k
@r_Unity3D
This media is not supported in your browser
VIEW IN TELEGRAM
This is a short video of enemy drones from 'Planetarian'. 'Planetarian' is TPS Bullet-Hell game I'm developing for the first time. Please leave any thoughts and feedback.

https://redd.it/1i1mnec
@r_Unity3D
After six months of development, I am finally able to release the first version of "Desktop Capybaras" on Itch.io
https://redd.it/1i1e8bn
@r_Unity3D
Can't move child in prefab instance but...

Hey all. I have a prefab instance like this:

PrefabInstance
- Child1
- Child2
- ChildThatShouldBeAtTheTop

I try to move the 3rd child so that it's the first but it of course tells me I cannot do that in the prefab instance. I then edit the prefab but it looks like this already:

PrefabInstance
- ChildThatShouldBeAtTheTop
- Child1
- Child2

It seems the order in the prefab and instance are different and I can't do anything about it. How do I move the children in the instance in this situation?

https://redd.it/1i1qf7j
@r_Unity3D
This media is not supported in your browser
VIEW IN TELEGRAM
Working on new text animations. How do the animations and pacing feel? Is the text speed right, or would you want to hit skip?

https://redd.it/1i1t8ti
@r_Unity3D