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
Media is too big
VIEW IN TELEGRAM
Made a fire stream out of symbols. Does it look good? Current battle gameplay: everything shoots automatically. You just reload, maybe craft something mid-fight (like a shield or a support drone) and escape in time. Still deciding if I should rework it to give the player more control...

https://redd.it/1gzkvwt
@r_Unity3D
2D Platform Game for School Project... NEED HELP

Hey guys, this is my code in C# that i actually got from chatGPT because im not really good in coding haha... The problem is that for player2 (frog) it is not actally reseting horizontal velocity only after landing but its like allways... and if there is no reseting of horizontal velocity the frog is sliding after landing.. Can anybody help me with that somehow?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TwoPlayerMovement : MonoBehaviour
{
    Header("Player 1 Settings")
    public Rigidbody2D rb1;
    public Transform groundCheck1;
    public LayerMask groundLayer1;
    private float horizontal1;
    private float speed1 = 8f;
    private float jumpingPower1 = 16f;
    private bool isFacingRight1 = true;

    Header("Player 2 Settings (Frog)")
    public Rigidbody2D rb2;
    public Transform groundCheck2;
    public LayerMask groundLayer2;
    private bool isGrounded2;
    private bool isChargingJump2 = false;
    private bool wasInAir2 = false; // Detects if the frog was previously in the air
    private float chargeTime2 = 0f;
    private float maxChargeTime2 = 1.5f; // Maximum charge time
    private float minJumpPower2 = 6f; // Minimum jump strength
    private float maxJumpPower2 = 16f; // Maximum jump strength
    private float jumpDirection2 = 0f; // Direction of the jump (-1 = left, 1 = right)
    private bool isFacingRight2 = true;

    private void Update()
    {
        // Player 1 Controls
        horizontal1 = Input.GetAxisRaw("HorizontalP1"); // Custom axis for Player 1
        if (Input.GetButtonDown("JumpP1") && IsGrounded(groundCheck1, groundLayer1))
        {
            rb1.velocity = new Vector2(rb1.velocity.x, jumpingPower1);
        }
        if (Input.GetButtonUp("JumpP1") && rb1.velocity.y > 0f)
        {
            rb1.velocity = new Vector2(rb1.velocity.x, rb1.velocity.y 0.5f);
        }

        Flip(ref isFacingRight1, horizontal1, rb1.transform);

        // Player 2 (Frog) Controls
        isGrounded2 = IsGrounded(groundCheck2, groundLayer2);

        if (isGrounded2)
        {
            // If frog just landed, reset horizontal velocity
            if (wasInAir2)
            {
                rb2.velocity = new Vector2(0f, rb2.velocity.y); // Reset horizontal velocity only after landing
                wasInAir2 = false;
            }

            // Start charging the jump
            if (Input.GetButtonDown("JumpP2"))
            {
                isChargingJump2 = true;
                chargeTime2 = 0f;
            }

            // Set jump direction based on input
            float inputHorizontal = Input.GetAxisRaw("HorizontalP2");
            if (inputHorizontal != 0)
            {
                jumpDirection2 = inputHorizontal > 0 ? 1f : -1f;
                isFacingRight2 = jumpDirection2 > 0;
                Flip(ref isFacingRight2, jumpDirection2, rb2.transform);
            }
        }

        // Charge the jump
        if (isChargingJump2)
        {
            chargeTime2 += Time.deltaTime;
            chargeTime2 = Mathf.Clamp(chargeTime2, 0f, maxChargeTime2); // Limit to max charge time
        }

        // Release the jump
        if (Input.GetButtonUp("JumpP2") && isChargingJump2)
        {
            isChargingJump2 = false;

            // Calculate jump power based on charge time
            float jumpPower = Mathf.Lerp(minJumpPower2, maxJumpPower2, chargeTime2 / maxChargeTime2);

            // Apply the jump
            rb2.velocity = new Vector2(jumpDirection2
jumpPower, jumpPower);

            // Mark that the frog is in the air
            wasInAir2 = true;
        }
    }
    private void FixedUpdate()
    {
        // Apply horizontal movement for Player 1 only
        rb1.velocity = new Vector2(horizontal1 speed1, rb1.velocity.y);

        // The frog retains its horizontal velocity when grounded
        if (!isGrounded2 && !wasInAir2)
        {
            // Keep horizontal velocity in the air until the jump is released
            rb2.velocity = new Vector2(rb2.velocity.x, rb2.velocity.y);
        }
    }

    private bool IsGrounded(Transform groundCheck, LayerMask groundLayer)
    {
        // Check if the player is on the ground (groundLayer)
        return Physics2D.OverlapCircle(groundCheck.position, 0.2f, groundLayer);
    }

    private void Flip(ref bool isFacingRight, float horizontal, Transform playerTransform)
    {
        if (isFacingRight && horizontal < 0f || !isFacingRight && horizontal > 0f)
        {
            isFacingRight = !isFacingRight;
            Vector3 localScale = playerTransform.localScale;
            localScale.x
= -1f;
            playerTransform.localScale = localScale;
        }
    }

    private void OnDrawGizmos()
    {
        // Draw the ground check areas for debugging
        if (groundCheck1 != null)
        {
            Gizmos.color = Color.green;
            Gizmos.DrawWireSphere(groundCheck1.position, 0.2f);
        }
        if (groundCheck2 != null)
        {
            Gizmos.color = Color.blue;
            Gizmos.DrawWireSphere(groundCheck2.position, 0.2f);
        }
    }
}

https://redd.it/1gzm1by
@r_Unity3D
Click on shapes and do some letter combination... the game. I made it. Go play it

Don't be a SQUARE is fucking out now. Click on the shapes or whatever and do some letter combination shit. You won't win cause its kinda hard. I didn't finish it. Go play it!

https://differentpixels.itch.io/dont-be-a-square

https://redd.it/1gzqmjk
@r_Unity3D
This media is not supported in your browser
VIEW IN TELEGRAM
A Little Animation Explaining how Meshes are Rendered for a Video I'm Working on

https://redd.it/1gzml6q
@r_Unity3D
This media is not supported in your browser
VIEW IN TELEGRAM
Here’s the Trailer for out first game, SPIN Protocol. Demo now playable on Steam. We’d love your feedback!

https://redd.it/1gzoga8
@r_Unity3D
I have a Singleton Manager. Does it matter if I write " foo " or " Manager.foo " when I'm writing code inside the Manager class ?
https://redd.it/1gzquqp
@r_Unity3D
This media is not supported in your browser
VIEW IN TELEGRAM
Added a weather system to our procedural freeriding skiing game SNØ - What riding with clear skies vs. during a snow storm looks like

https://redd.it/1gzp5ia
@r_Unity3D
This media is not supported in your browser
VIEW IN TELEGRAM
a Minigame Mechanic from Party Spirits, my Upcoming 2-6 Player Online Party Game
https://redd.it/1gzxs9i
@r_Unity3D
Difficulty of a 2 player card game? - Mirror

Hello, experienced C# dev for my profession, dabbled a bit in unity. I understand the feeling of being in over your head by trying to make a 3d hack and slash game, and it’s just too much. I want to make something simpler and fun. I figured a card game would be very component based, so once the uphill battle of initial setup and multiplayer setup is done, I can get rolling.

However, how difficult of a project is this, comparatively? I understand there is a scale between simple 2d platformer and MMO, where does this fall on the scale ?

https://redd.it/1gzwxza
@r_Unity3D
It's been over 10 years and you still can't add enums as an argument to button functions
https://discussions.unity.com/t/ability-to-add-enum-argument-to-button-functions/551773/186

https://redd.it/1h02bvr
@r_Unity3D
Has anyone had and experience with GPU Instancer Pro? I want to know if this will actually improve the performance of my projects?
https://redd.it/1gzulmr
@r_Unity3D
How can I efficiently crop and resize 2D UVs to custom map?
https://redd.it/1h06akw
@r_Unity3D
Unity accounts suspended after releasing our indie game on Steam
https://redd.it/1h07q5n
@r_Unity3D
This media is not supported in your browser
VIEW IN TELEGRAM
Created my fastest new weapon by changing bullets to bigger fire bullets to end up with a flame thrower instead of a shotgun. Love when systems works as designed!

https://redd.it/1h08our
@r_Unity3D
My 2D pixel art player sprite is too big.

I have made a player sprite that I absolutely love, however it is extremely big.

Because I'm in pixel art, I can't lower the sprite's transform scale value, it will be weird. I can't tweak the sprite itself, because of its tall structure.

Is there a way to making it smaller, without making making another sprite entirely?

https://redd.it/1h0atq5
@r_Unity3D
Does anyone else do this to force important folders to the top? Is there a better way?
https://redd.it/1h0drvx
@r_Unity3D