r/Unity3D – Telegram
r/Unity3D
266 subscribers
12.7K 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
Player falls into ground when crouching Help

So rn im Creating a simple 2d Platformer for a school Project and i want to implement a crouch mechanic the code initself is working but whenever press Left shift for crtouch the player falls through the ground can anybody help me




here is the code for my Player Movment


using UnityEngine;



public class Movment : MonoBehaviour

{

[Header("Bewegungseinstellungen")\]

public float moveSpeed = 5f;

public float jumpForce = 12f;



[Header("Bodenüberprüfung")\]

public Transform groundCheck;

public float groundCheckRadius = 0.2f;

public LayerMask groundLayer;



[Header("Sprite Einstellungen")\]

public Sprite idleSprite;

public Sprite moveLeftSprite;

public Sprite moveRightSprite;

public Sprite duckLeftSprite;

public Sprite duckRightSprite;

public Sprite duckIdleSprite;



private Rigidbody2D rb;

private SpriteRenderer spriteRenderer;

private BoxCollider2D boxCollider;

private float moveInput;

private bool isGrounded;

private bool isDucking = false;



void Start()

{

rb = GetComponent<Rigidbody2D>();

spriteRenderer = GetComponent<SpriteRenderer>();

boxCollider = GetComponent<BoxCollider2D>();



if (groundCheck == null)

{

Debug.LogError("GroundCheck Transform ist nicht zugewiesen! Bitte im Inspector setzen.");

}



if (spriteRenderer == null)

{

Debug.LogError("SpriteRenderer Komponente fehlt am Spieler GameObject.");

}



if (boxCollider == null)

{

Debug.LogError("BoxCollider2D Komponente fehlt am Spieler GameObject.");

}

}



void Update()

{

// Input Left Right A/D

moveInput = 0f;

if (Input.GetKey(KeyCode.A))

moveInput = -1f;

else if (Input.GetKey(KeyCode.D))

moveInput = 1f;



// Bodencheck

isGrounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, groundLayer);



// Sprung

if (isGrounded && Input.GetKeyDown(KeyCode.Space))

{

rb.velocity = new Vector2(rb.velocity.x, jumpForce);

}



// Ducken

if (Input.GetKey(KeyCode.LeftShift) && isGrounded)

{

isDucking = true;

boxCollider.size = new Vector2(boxCollider.size.x, boxCollider.size.y / 1.5f);

}

else if (Input.GetKeyUp(KeyCode.LeftShift) || !isGrounded)

{

isDucking = false;

boxCollider.size = new Vector2(boxCollider.size.x, boxCollider.size.y * 1.5f);

}



// Sprite Change for Driection

UpdateSprite();

}



void FixedUpdate()

{





if (isDucking)

{

rb.velocity = new Vector2(rb.velocity.x, 0f);

}

else

{

rb.velocity = new Vector2(moveInput * moveSpeed, rb.velocity.y);

}





}



void UpdateSprite()

{

if (isDucking)

{

if (moveInput == 0)

{

if (duckIdleSprite != null)

{

spriteRenderer.sprite = duckIdleSprite;

}

}

else if (moveInput < 0)

{

if (duckLeftSprite != null)

{

spriteRenderer.sprite = duckLeftSprite;

}

}

else if (moveInput > 0)

{

if (duckRightSprite != null)

{

spriteRenderer.sprite = duckRightSprite;

}

}

}

else

{

if (moveInput < 0)

{

if (moveLeftSprite != null)

{

spriteRenderer.sprite = moveLeftSprite;

}

}

else if (moveInput > 0)

{

if (moveRightSprite != null)

{

spriteRenderer.sprite = moveRightSprite;

}

}

else

{

// idle

if (idleSprite != null)

{

spriteRenderer.sprite = idleSprite;

}

}

}

}



void OnDrawGizmosSelected()

{

if (groundCheck != null)

{

Gizmos.color = Color.green;

Gizmos.DrawWireSphere(groundCheck.position, groundCheckRadius);

}

}

}

some of the code is in German because i am and i tent to mix my language up for my ground i dont have any code

https://redd.it/1kvqf60
@r_Unity3D
Question Photon Pun 2

Hello,
I have a question.
I use photon pun 2 at the moment. All works great except when there are too many instances of physic objects.
Let's say there are like just boxes falling from the sky, for a number of 10 boxes all works fine, no synchronisation problems.

Bur when there are 20 boxes at once, there are synchronisation problems, the boxes don't respect the law of physics anymore.

So my 2 questions are:
-is there anything i can do, that it also works with a higher numer of physical objects
-is this problem also with photon fusion?

Thanks

https://redd.it/1kvs4ag
@r_Unity3D
Looking for Indie Devs to Interview for My Master's Thesis on Game Pricing Decisions

Hi everyone,

I'm currently working on my Master's thesis in business/economics, focusing on how indie developers make pricing decisions for their games. As a hobby dev myself and regular reader of this sub, I’ve noticed that many indie devs seem to base their pricing on similar noscripts or genre leaders. I want to explore how common this approach is and what role economic reasoning plays in the process.

The main question I'm trying to answer is:
Why do indie developers price their games the way they do, and are they potentially underpricing them?

To get meaningful insights, I’m conducting short interviews (about 15 minutes over Discord) where I’ll ask a few questions about how you arrived at your game's price.

# Requirements to participate:

Able to speak English at a conversational level
Have published at least one commercial game on Steam (not free-to-play)
Willing to do a short voice or text interview on Discord
All interviews will be fully anonymized and used solely for academic purposes

If you’re interested (or know someone who might be), feel free to comment or DM me. Your input would be a huge help and greatly appreciated.

Thanks in advance for your support, and best of luck with your projects!

https://redd.it/1kvvn7z
@r_Unity3D
This media is not supported in your browser
VIEW IN TELEGRAM
I recreated the holographic foil card effect from Pokémon TCG Pocket using Render Objects and Shader Graph in URP, and made a full tutorial explaining how

https://redd.it/1kvw9dz
@r_Unity3D
My kid wants to use Unity...

He's 10 and has already mastered scratch, and he knows how to do 8bit coding. I know nothing about coding. He wants to use unity. Is it safe? Any good tutorials? They have one from 2020 parents and kids code together, but has the software changed dramatically since then? He wants something more challenging. Is there another program that is a better step above scratch but not as complex as unity?


Other questions: Does this take up a lot of storage? Would it be possible to use an external hard drive for this program so it doesn't take over my computer storage? Can we use this without downloading it?

Sorry if these are silly questions, computers aren't my thing, just trying to support my kid.

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