r/Unity3D – Telegram
r/Unity3D
259 subscribers
12.6K photos
15.5K videos
14 files
47.8K 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
After a year of development and polishing, My memory-game roguelike now has a release trailer! Let me know what you think & does it explain the game well?

https://redd.it/1hp8ceh
@r_Unity3D
What is considered best practice as far as propelling an object forward?

Thinking of ditching setting up velocity alltogether, and just adding force instead. Any potential pitfalls that I might be missing? This is for Top down perspective.

https://redd.it/1hpboit
@r_Unity3D
Can someone help mmake this shotgun work

On the shot gun object i have 5 emptys that the bullets spawn at. some are angled so the shot gun has a spread but that's not working. I think it is because even though their spawning angled, the velocity is still the vector2 from the mouse and player. I've been trying everything I can think of for about 30 minutes. A lot of this code is Chat gpt and I understand most of it but I'm still not skilled to enough to fix this problem. Thank you for anyhelp



{

public Transform player;

public Rigidbody2D PlayerRb;

public float orbitRadius = .2f;

public GameObject bulletPrefab;

public Transform firePoint1;

public Transform firePoint2;

public Transform firePoint3;

public Transform firePoint4;

public Transform firePoint5;

public float bulletSpeed = 10f;



private Vector3 mousePosition;



void Update()

{

if (player == null)

{

Debug.LogWarning("Player reference is missing.");

return;

}



mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

mousePosition.z = 0; // Mkae sure z is 0 for 2D space



Vector2 directionToMouse = (mousePosition - player.position).normalized;



Vector2 orbitPosition = (Vector2)player.position + directionToMouse * orbitRadius;

transform.position = orbitPosition;



// Rotate the gun to face the mouse

float rotationAngle = Mathf.Atan2(directionToMouse.y, directionToMouse.x) * Mathf.Rad2Deg;

transform.rotation = Quaternion.Euler(0, 0, rotationAngle);



// Flip the gun if it's on the left side of the player

if (directionToMouse.x < 0)

{

transform.localScale = new Vector3(1, -1, 1); // Flip vertically



}

else

{

transform.localScale = new Vector3(1, 1, 1); // Normal orientation

}

if (Input.GetMouseButtonDown(0)) // Left mouse button

{

Shoot(directionToMouse);

}

}



void Shoot(Vector2 direction)

{

Debug.Log(direction);

if (bulletPrefab == null || firePoint1 == null)

{

Debug.LogWarning("Bullet prefab or fire point is missing.");

return;

}



// Store the fire points in an array

Transform[] firePoints = { firePoint1, firePoint2, firePoint3, firePoint4, firePoint5 };



// Loop through each fire point

foreach (Transform firePoint in firePoints)

{

// Instantiate the bullet at the fire point

GameObject bullet = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);



// Apply velocity to the bullet

Rigidbody2D rb = bullet.GetComponent<Rigidbody2D>();

if (rb != null)

{

rb.velocity = direction * bulletSpeed + PlayerRb.velocity;

}

}

}

}

https://redd.it/1hpfaqj
@r_Unity3D
Educational Books for Unity 2D?

What are some books or e-books I should pickup to learn how to build games in 2D with Unity?

https://redd.it/1hpgbzn
@r_Unity3D
can someone tell me what this EditorLoop is and what causes it so that it makes my game drop so many frames??
https://redd.it/1hpbky3
@r_Unity3D
Where do i start?

For context. i want to learn game dev or coding for the frist time. i am pretty confused where to start.

so could someone give good advive or a good tutorial?

Thanks!

https://redd.it/1hp5bpz
@r_Unity3D
How to optimize the generation of a lot of GameObjects at once

I have a mining game where each square is a gameobject, and I need to instantiate 4,800 of them (3 sets of 1,600) when the game starts. (The world is procedurally generated, and when the player mines an entire set, another set of 1,600 is generated, while the topmost set is deleted.)

I've already optimized performance with the shadow that appears (the black part in the image). Essentially, as long as a block isn't discovered, it doesn't perform any functions, and its rigidbody and colliders are disabled, but i still have to instantiate them all.

The issue is that the game lags when the player clicks to start the game and when a new set is generated, even though the lag is smaller in the latter case.

How can I optimize this further? I thought about adding a loading screen before the game starts, but what about when the game is already running?

About the code, it generate the blocks in a matrix of strings first, and them loops through every cell of the matrix instantiating the respective block one by one.

I appreciate any tips or suggestions!

https://preview.redd.it/63agn5y6rz9e1.png?width=1296&format=png&auto=webp&s=33b0f285bcc438c581cab4d70bd3f9bcd0ca8dfe

https://preview.redd.it/bip9os0arz9e1.png?width=1296&format=png&auto=webp&s=b6ad791c55b4c1ad7442f12b688d2ec526a4bc64

https://preview.redd.it/g89bzgvjrz9e1.png?width=636&format=png&auto=webp&s=9655ede983c98e85159cb98dc6d50199db76c4bd




https://redd.it/1hpnnpu
@r_Unity3D
Shader graph doesn't update properly

I'm trying to fake 2d shadow by using Shader Graph. A child object of the player will get sprite from parent every frame and then turn it in to shadow with shader. Problem is it doesn't render every few frame, and it is slower than the texture updating. If I don't use the shader then the child object update fine, showing same texture as the player. (I plan to optimize the shader after fixing this so it looks awful right now haha...)
https://drive.google.com/file/d/1jcRiL0ZxGkqT4dD5yM2WBTLe001\_wUkf/view?usp=drive\_link

https://redd.it/1hpq3b3
@r_Unity3D
Webgl ads / gartic phone game

We havent been abls to find a a way to put ads in webgl games , anyone knows what gartic phone uses for full page ads? Or any webgl ad networks?

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