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
Media is too big
VIEW IN TELEGRAM
Anyone know who this cameo is? Or am I the only one who is old!

https://redd.it/1i44zkq
@r_Unity3D
Collectibles - UI communication in Unity ECS and animation with DOTween + MVC pattern 🍻
https://redd.it/1i482l5
@r_Unity3D
New video breaking down how I made $500,000 from my Unity game. What do you think?

I just posted a new video covering the performance of my first commercial Unity project, This Means Warp (approx $500k net revenue).

Hope it's interesting for any indie devs looking at making a living from games. Happy to answer any questions so if you're curious just drop a comment and I'll share as much as I can!

https://redd.it/1i47odx
@r_Unity3D
What do you think about embedded documentation in Unity Assets?
https://redd.it/1i4a6kp
@r_Unity3D
Media is too big
VIEW IN TELEGRAM
4 months in 1 minute! 🎮 From day one to now. Morning Star

https://redd.it/1i4br55
@r_Unity3D
This media is not supported in your browser
VIEW IN TELEGRAM
1 vs 7 battle in my game! Enemies surround the target and do not allow him to escape, so be prepared!

https://redd.it/1i4d6xg
@r_Unity3D
Respawn issue

Hi, I am a beginner trying to create code that will respawn the player at the last platform they were on. But for some reason when I go to a new platform, the prefab is being changed to null, because I get a message saying the prefab hasn't been assigned. My debug code tells me that the collisions are being detected with each platform.

All the platforms are sprites with RigidBody2Ds with BoxCollider2D components. They have no noscripts attached to them.

Bug behavior recording

Inspector screenshot

Thank you in advance for any help or insight you can provide! Please let me know if I screwed up any etiquette -- this is my first post here.

Here is the noscript attached to my Player

using UnityEngine;

public class Player : MonoBehaviour
{
// Set the speed and jumping variables
public float speed = 5.0f;
public float jumpForce = 10.0f;
public float doubleJumpForce = 60.0f;
private int jumpcount = 0;

public GameObject playerPrefab; // Reference to the player prefab
public float respawnYOffset = 300f; // Vertical offset for respawning above the platform

private Rigidbody2D rb;

private GameObject lastPlatform;

void Start()
{
rb = GetComponent<Rigidbody2D>();
}

// Update is called once per frame
void Update()
{
// Check if the player has fallen off the screen
float bottomEdgeY = Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0f, Camera.main.nearClipPlane)).y;

if (transform.position.y < bottomEdgeY)
{
Debug.Log("Player fell off the screen!");
Debug.Log("Falling off. Last platform: " + (lastPlatform != null ? lastPlatform.name : "null"));
RespawnPlayer();
};

// Input movement
if (Input.GetKey(KeyCode.A))
{
transform.position += Vector3.left speed Time.deltaTime;
}
if (Input.GetKey(KeyCode.D))
{
transform.position += Vector3.right speed Time.deltaTime;
}
if (Input.GetKeyDown(KeyCode.Space) && jumpcount == 0)
{
rb.AddForce(Vector2.up jumpForce, ForceMode2D.Impulse);
jumpcount++;
}
else if (Input.GetKeyDown(KeyCode.Space) && jumpcount == 1)
{
rb.AddForce(Vector2.up
doubleJumpForce, ForceMode2D.Impulse);
jumpcount = 0;
}
}

private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Ground"))
{
Debug.Log($"Collision ENTER detected with: {collision.gameObject.name}");
lastPlatform = collision.gameObject;
Debug.Log($"Last platform updated to: {lastPlatform.name}");
}
}
private void OnCollisionExit2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Ground"))
{
Debug.Log($"Collision EXIT detected with: {collision.gameObject.name}");
}
}

private void RespawnPlayer()
{
Debug.Log("playerPrefab: " + (playerPrefab != null ? "Assigned" : "Null"));
if (lastPlatform != null) // Ensure there's a valid platform to respawn on
{
// Calculate respawn position
Vector3 respawnPosition = lastPlatform.transform.position;
respawnPosition.y += respawnYOffset; // Add Y offset to spawn above the platform

// Destroy the current player GameObject (if necessary)
Destroy(gameObject);

// Instantiate a new player at the respawn position
Instantiate(playerPrefab, respawnPosition, Quaternion.identity);

Debug.Log("Player respawned at: " + respawnPosition);
}
else
{
Looking For Free 2d TopDown Assets

Hi all

I'm just starting out on my gamedev journey so i would like to know where i can find some top down 2d assets especially top down style tilesets that are dungeon based if possible.
I would like to just work on a small 2d project so i can get the feel of completing a project.



https://redd.it/1i4hd8x
@r_Unity3D
Media is too big
VIEW IN TELEGRAM
I'm making improvements to the feel before the demo. I improved the camera feel. What do you think?

https://redd.it/1i4eem2
@r_Unity3D
Me and the rest of the dev team were testing the network.
https://redd.it/1i4lnwr
@r_Unity3D
Issue with Touch Input on Android Phone

I am having issues when building my test game for my android phone. I am trying to make a simple platformer with on-screen buttons. The buttons work in the unity simulator, but they do not work when on my phone. The buttons light up, but they do not trigger the action. If I keep tapping them, sometimes they will randomly work. I have checked my input system and noscript, and I can't not find a reason why it's not working. Any advice would be appreciated. I am including the Input system build, the player input component, and the player movement noscript.

https://preview.redd.it/4ljwhorkuvde1.png?width=928&format=png&auto=webp&s=3d8a00c52e837600a89605164ddb68fed6fa4779

[Star = Player](https://preview.redd.it/k8qlm59puvde1.png?width=458&format=png&auto=webp&s=f050860aeb263e319dce968aa6980c2fbc8e3306)

`using Unity.VisualScripting;`

`using UnityEngine;`

`using UnityEngine.InputSystem;`



`public class StarControls : MonoBehaviour`

`{`

`private Rigidbody2D star;`

`private PlayerInput playerInput;`

`private bool hasMoved = false;`





`[SerializeField] private float moveSpeed = 1f;`

`[SerializeField] private float acceleration = 1f;`

`[SerializeField] private float maxVelocity = 6f;`

`[SerializeField] private LevelTimer levelTimer; //Need to move this to the gama manager as a start game function`

`[SerializeField] private GameStateManagementScript gameManager;`



`private InputAction moveAction;`

`private InputAction jumpAction;`

`private InputAction pauseAction;`



`private Vector2 moveInput;`

`private bool jumpInput;`

`private float isPaused;`



`private bool canJump = false;`

`[SerializeField] private float jumpForce = 1f;`

`[SerializeField] private Transform groundCheck; // Empty GameObject placed at the player's feet`

`[SerializeField] private float groundCheckRadius = 0.05f; // Radius of the ground check`

`[SerializeField] private LayerMask groundLayer; // Layer mask for what is considered ground`

`private bool isGrounded = false;`





`private void Start()`

`{`

`star = GetComponent<Rigidbody2D>();`

`playerInput = GetComponent<PlayerInput>();`



`moveAction = playerInput.actions["Move"];`

`jumpAction = playerInput.actions["Jump"];`

`pauseAction = playerInput.actions["Pause"];`



[`//pauseAction.performed`](//pauseAction.performed) `+= OnPausePressed;`

`canJump = true;`



`}`

`private void Update()`

`{`

`if (moveAction.IsPressed())`

`{`

`Move();`

`}`

`Move();`

`if (jumpAction.IsPressed())`

`{`

`Jump();`

`}`

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

`if (isGrounded)`

`{`

`onLand();`

`}`

`if (moveInput.y > 0 && canJump && Mathf.Abs(star.linearVelocityY) < maxVelocity)`

`{`

`star.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse);`

`canJump = false;`

`}`

`else if (moveInput.x > 0 && star.linearVelocityX < maxVelocity)`

`{`

`star.AddForce(new Vector2(moveInput.x * moveSpeed,0), ForceMode2D.Impulse);`

`}`

`else if (moveInput.x < 0 && star.linearVelocityX > (maxVelocity * -1))`

`{`

`star.AddForce(new Vector2(moveInput.x * moveSpeed, 0), ForceMode2D.Impulse);`

`}`

`if (!hasMoved && moveInput != Vector2.zero)`

`{`

`hasMoved = true;`

`levelTimer.StartTimer();`

`}*/`

`}`

`private void onLand()`

`{`

`canJump = true;`

`if (star.linearVelocity.x == 0)`

`{`

`return;`

`}`

`float decelerationDirection = -Mathf.Sign(star.linearVelocity.x);`

`star.AddForce(new Vector2(decelerationDirection * acceleration, 0), ForceMode2D.Impulse);`



`if (Mathf.Abs(star.linearVelocityX) < 0.5)`

`{`

`star.linearVelocityX = 0;`

`}`

`}`

`void OnDrawGizmos()`

`{`

`// Visualize the ground check in the editor`

`if (groundCheck != null)`

`{`

`Gizmos.color =` [`Color.red`](http://Color.red)`;`

`Gizmos.DrawWireSphere(groundCheck.position, groundCheckRadius);`

`}`

`}`

`/*private void OnPausePressed(InputAction.CallbackContext context)`

`{`

`gameManager.TogglePauseGame();`

`}`

`private void OnDestroy()`

`{`

`// Unsubscribe to avoid memory leaks`

`pauseAction.performed -=
OnPausePressed;`

`}*/`

`public void OnMove(InputValue context)`

`{`

`Debug.Log("OnMove");`

`moveInput = context.Get<Vector2>();`

`}`

`private void Move()`

`{`

`Debug.Log("Move" + moveInput);`

`if (moveInput.x > 0 && star.linearVelocityX < maxVelocity)`

`{`

`star.AddForce(new Vector2(moveInput.x * moveSpeed, 0), ForceMode2D.Impulse);`

`}`

`else if (moveInput.x < 0 && star.linearVelocityX > (maxVelocity * -1))`

`{`

`star.AddForce(new Vector2(moveInput.x * moveSpeed, 0), ForceMode2D.Impulse);`

`}`

`if (!hasMoved && moveInput != Vector2.zero)`

`{`

`hasMoved = true;`

`levelTimer.StartTimer();`

`}`

`}`

`/*public void OnJump()`

`{`

`}*/`

`private void Jump()`

`{`

`Debug.Log("Jump");`

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

`if (isGrounded)`

`{`

`onLand();`

`}`

`if (canJump && Mathf.Abs(star.linearVelocityY) < maxVelocity)`

`{`

`star.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse);`

`canJump = false;`

`}`

`}`

`public void OnPause()`

`{`

`gameManager.TogglePauseGame();`

`}`

`}`


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