r/Unity3D – Telegram
r/Unity3D
265 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
infinite jump

hey guys , i got infinite jumping in my unity project but i dont want it . i tried a code from a tutorial but it doesnt work . here it is

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


public class PlayerController : MonoBehaviour
{
    [Header("Horizontal Movement Settings")]
    // variable
    private Rigidbody2D rb;
    [SerializeField] private float walkspeed = 10;
    private float xAxis;
   
    [Header("ground check settings")]
    [SerializeField] private float jumpForce = 45;
    [SerializeField] private Transform GroundCheckPoint;
    [SerializeField] private float groundCheckY = 0.2f;
    [SerializeField] private float groundCheckX = 0.5f;
    [SerializeField] private LayerMask whatIsGround;

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        getInputs();
        move();
        jump();

        if (Input.GetButtonDown("Jump"))
        {
            rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpForce);
        }
    }

// Permet de recevoir les touches presse par le joueur et leur attribues une action
    void getInputs()
    {
        xAxis = Input.GetAxisRaw("Horizontal");
    }


    void move()
    {
        rb.linearVelocity = new Vector2(walkspeed * xAxis, rb.linearVelocity.y);
    }

    public bool Grounded()
    {            //permet de verifier si le joueur est sur une plateforme ou non
        if (Physics2D.Raycast(GroundCheckPoint.position, Vector2.down, groundCheckY, whatIsGround)
            || Physics2D.Raycast(GroundCheckPoint.position + new Vector3(groundCheckX, 0, 0), Vector2.down, groundCheckY, whatIsGround)
            || Physics2D.Raycast(GroundCheckPoint.position + new Vector3(-groundCheckX, 0, 0), Vector2.down, groundCheckY, whatIsGround))
        {
            return true;
        }
        else
        {
            return false;
        }

    }

    void jump()
    {
        if(Input.GetButtonUp("Jump") && rb.linearVelocity.y > 0)
        {
            rb.linearVelocity = new Vector2(rb.linearVelocity.x, 0);  //permet dannuler le jump en pleine air
        }
        if(Input.GetButtonDown("Jump") && Grounded())
        {
            rb.linearVelocity = new Vector3(rb.linearVelocity.x, jumpForce);
        }
       
    }
}


https://redd.it/1kn2wz0
@r_Unity3D
This media is not supported in your browser
VIEW IN TELEGRAM
We've been working on a game about organizing colorful stuff, finally feels like it’s taking shape!

https://redd.it/1kn3vgc
@r_Unity3D
Sprite is clipping

https://preview.redd.it/hgq9juw5ix0f1.png?width=1919&format=png&auto=webp&s=ae9556b3dd3af5f1ae2027175c45ada5501e8508

When i walk arround the sprite it goes like this an i dont know how to fix it. I you have anny questions u can ask

https://redd.it/1kn5jg7
@r_Unity3D
Dealing with tiles "squareness"
https://redd.it/1kn7icm
@r_Unity3D
Am I missing something about shaders?

Hi everyone,

I've came back to unity after a couple of years, and tried to add a simple full-screen effect on my 2D game. The idea is simple: take the current frame, take the previous frame, and display the pixel wise difference between the two.

I've looked at at least 5 different tutorials about Shaders, Render Features, Volume Render Features, Shader Graph etc. and none of them have given me a working result. I even tried to use ChatGPT as a last resort to try to get a minimal example working, but to no avail. Something was always wrong, incompatible, or not working. I am therefore asking the question:

Is there something fundamentally complicated with Unity's URP, or am I missing something obvious to create simple custom post-processing effects?


Thank you in advance, for context I'm a Software Engineer by trade, and manage to get most of what I want in Unity to work, but I'm stumped that I wasted hours on something that I expected to be simple.

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