#archived-code-general
1 messages · Page 422 of 1
yes the collectable just Calls the method Score, then that method does its own Invoke of the event, the event lives on score script because it makes sense for a score tracker to have an alert to when score update. You should not make the method static though otherwise you cannot reference anything else within that class without it also be static which can be a mess
also static fields don't show up in unity so you cannot even link anything like reference through it
If you haven't already would strongly recommend you check out the singleton pattern for things like managers / trackers of data
https://gamedevbeginner.com/singletons-in-unity-the-right-way/
https://unity.huh.how/references/singletons
this makes the one spawned Instance(object) of that class static, makes it easy to access its methods / properties without having to make everything else static
I was actually already using a singleton.
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Does this look about right? I didn't have anything else yet that could listen to the event, so I couldn't quickly test it.
in that case no point Score being static
notice how you could only access score through instance in its static method
so yeah if you have singleton, everything else does not need to be static, just public if you want acces to them elsewhere. like method
I think I'm doing something slightly wrong.
THis is what happens when I try to make Score non-static. The game actually keeps running, but the line in the cups that should destroy them doesn't fire either.
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
I have encountered weird problem with loaded data.
My data is stored with the help of a binary formatter, with every generated league, team, player and manager kept as a list of lists, with entries storing all the data i need. Code seems to work just fine, however - the following issue has appeared!
After loading data, my game starts progressing through the days much slower, both in editor and after i build and run it. I can't figure out what the issue is, can someone please give me at least a direction of where to look? I suspected the problem may have been in save file not being closed, but i think it should be getting closed just fine in first screenshot.
Second screenshot shows typical example of me loading data to re-create an object that was saved.
thats because its private
normally its serialized in the inspector so it doesnt need null checking
If you dont want to use inspector at all just use an Action
What's private? the Score method is public.
And in the collectible I add it via collected.AddListener(ScoreScript.instance.Score);
line 28 is this
scoreEvent.Invoke(score);
thi is like the complete opposite of what you should do lol
wait nvm
https://discordapp.com/channels/489222168727519232/763495187787677697/1340034446132379658
look at the example again
Yeah, I got mixed up.
the null is thrown because if your event has no listeners its null
{
ScoreScript.instance.Score();
Destroy(this.gameObject);
}```
otherwise you need myEvent?.Invoke()
Now it's working perfectly.
UnityEvent is okay for wen you need inspector
otherwise just stick to Action
Unity event only supports unity objects and int,float, string
or I think thats just for the inspector ? idk I just use Action tbh
I see. I'm probably gonna look into those too, then.
Also thanks a bunch for the patience and explanations :)
np 
Semi-related to this, is there any reason not to put all my static logic/manager classes (like that ScoreScript, the Audio Manager, and later maybe a Health Manager) onto the same empty GameObject? Or should each one of those get its own? (Provided they're supposed to do nothing more than hold the scripts)
thats entirely up to you . Whatever will be easier to find later on
personally find it easier sometimes on their own object cause I usuaully have other components that work with those managers that might not necessarily care about others
there are also very small performance implications.. even empty gameobject need to allocate resource to exist, so now you have extra allocation ontop of the script itself in small quanitities is probably non-issue but I guess with scale it can get ugly
I see. For the small practice stuff I'm doing rn, I'll probably leave them in one, but I guess when I do something bigger I should subdivide them a bit.
Thanks again.
im learning the dijkstra to traverse all possible position, finding furthest position and reachable positions at the same time, however all the guides i've seen only have use the algo for finding the shortest path between 2 pre designated points, anyone know a similiar implementation? or the steps to achieve this
Not quite sure what the question is. Dijkstra's algorithm is for finding the shortest path to the target. To traverse all possible positions you don't need pathfinding. Though you might want to look at the "traveling salesman problem" and different solutions that can be applied to it.
If there are extra conditions, you can just traverse all the positions in order.
running into an issue when running a build of my game.
the player has a collider attached to the main game object and another collider in a child object for the player
i have a script that finds the player and gets their collider.
in the unity editor, this works fine and the script successfully finds the collider on the player object
in the build of the game...the script finds the other collider on the child object.
you can see in the logs, two different object names are output. Bud is output in the editor (the correct game object), Combat is output in the build
whats with the discrepancy here?
please ignore how messy the code snippet is hehe
i think this is floodfilling? not dijkstra?
How do you assign the playerColl variable? Share the whole script.
Probably, floodfilling would definitely be better for the task than Dijkstra's algorithm.
You probably have several objects with the same tag. FindWithTag does not guarantee that the same object would be found.
GameObject.FindWithTag("Player")
Log the found object and see what it finds in the build
i did
you could be right about the tag thing
Then Combat had a player tag as well
its just weird that it always finds the right object when running the game in the unity editor but when running the build, it always finds the wrong object
Honestly, I'd avoid finding by tag at all
Yes, some things could be shuffled between the editor and the build
That's what it means that it doesn't guarantee order.
yeah, at some point i think im gonna switch over to some kind of global game manager that the passage can use to access the player object
ahh gotcha
seems to be fixed. thank you for the help ❤️
Hey how you guys doing just wanted to ask as a hipotetic question
You guys know valkyria cronicles 4? How much time would it take a expert proegrammer to make a simmilar sistem like that?
I mean it goes by turns, when its your turn its gree movement, etc. Just asking if you guys can help me with that
That's entirely dependent on you. People help in this channel if you ask specific coding questions (look at #854851968446365696 )
Although if you're asking about how to make turn based, I'd not be sure you're an expert
I had a coroutine with while(true) { yield return new WaitForSecondsRealtime(0.05f); text.text = "FPS: " + fps + " " + ms + "ms (avg " + fpsAvg + " " + msAvg + "ms)"; } and when I got rid of the yield it caused my unity to crash. Is that expected?
I don't mess around with coroutines much, but I guess it would cause an infinite loop without the delay.
Sorry, this question was meaningless
I need a suggestion.
I want to make multiplayer black jack game
Which multiplayer framework should i use? Photon or colyseus or something else?
Its a webgl game
And i want to cover up afk players or players in background
So i dont actually want to give authority to a single player like host
bcos there's no way to get out of the loop then it stackoverflows
no need to wrap that string manipulation in a while loop
I think the point was to refresh the variables, basically avoiding just using the Update loop
would've been less allocative to at least cache that if time didn't change
var waitTime = new WaitForSecondsRealtime(0.05f);
while(true) {
yield return waitTime
text.text = "FPS: " + fps + " " + ms + "ms (avg " + fpsAvg + " " + msAvg + "ms)";
}```
mb.. I didn't see the yield haha I need a coffee... that SO'd? it surprises me tbh
they removed the yield and that breaks inside while in ienumerator
yeh while loops in ienumerator always need to at least wait a frame with yield return null
or the frame basically never ends lol
yeah it will block the mainthread
If you want to measure FPS like this you can also just place it in an Update method rather than fiddling with coroutines
Just measure the time passed using Time.deltaTime and check the invokation count of Update when the time surpasses 1 second (with some additional checks to ensure you truly get the average per second but you get the idea)
If the world is based on grid, some sort of floodfill/BFS might work. However if you have stored the dungeon as a graph (positions of rooms and connecting edges between the rooms), you definitely need some sort of pathfinding algo. This article seems to present the variation of Dijkstras you are looking for https://www.geeksforgeeks.org/dijkstras-shortest-path-algorithm-greedy-algo-7/ (didn't read it too thoroughly to confirm it's any good)
Are you not supposed to be using Resources.Load anymore to load content from folders?
I'd like to grab some textures from a directory during game startup, any alternative ways? I've seen addressables but they seem to solve a somewhat different problem
What makes you think that
Stuff like this
And I've heard it a bunch of time around here
And nobody ever explained why. Just "don't use it"
Sure using Addressable lets you do more things but you can use Resources if you don’t care much about asset management
In the thread they kinda reffer to the "best practices" but it didn't make a lot of sense to me
From some of the games I've dissected I've seen some outright use C# methods to access files
I mean on corperation setting you’d use Addressable, for indie I doubt Resources will be issue
That’s more of StreamingAssets stuff
But you don’t get Unity-imported asset that way
magic strings are bad, in general. not super bad, but if there's an option between magic string and a reference, a reference would generally be better
What exactly is bad about them
I'm assuming it's acceptable when you need to load content that may be modified
Like modding or whatever
Neither Resources nor Addressable does not read from actual file system folder if that’s what you’re thinking of
Oh, so wouldn't have worked in a build anyway?
If you were thinking you can swap out png or something on built directory then no it won’t work that way
Alright, but this should work right?
If you change the name of something, like an audio file, suddenly code could stop working if you used magic strings.
This is bad
So thats finding shortest path for each node to start point, i think this would be way more consuming than simply floodfilling from the start point, what node reached sooner is shorter is it not ?
you don't get static checking, it's a big oppurtunity for mistakes (ie typos, desynced renaming/moving, removal) where it won't be flagged until it becomes an error at runtime
You can read file given by user sure, but you will only get raw file that way and not imported asset such as Texture/Sprite
mistakes are inevitable, it's better to catch them early (static checking and compiler errors are better than runtime errors, and that's better than silent bugs)
Should be possible to parse it
You can do it manually
The following code is responsible for making the player not double jump, and only jump on flatter-like surfaces. It worked perfect with the 3D capsule in unity, but now when I imported a character model with capsule collider, this code doesnt work in preventing double jumps at surfaces which are not flat (elevated)
{
CapsuleCollider capsule = GetComponentInChildren<CapsuleCollider>();
Vector3 boxCenter = capsule.bounds.center;
Vector3 boxHalfExtents = new Vector3(capsule.radius, groundCheckLengthOffset / 2, capsule.radius);
Quaternion orientation = Quaternion.identity;
Vector3 direction = Vector3.down;
float maxDistance = capsule.bounds.extents.y + groundCheckLengthOffset;
Debug.Log("Capsule Center: " + capsule.bounds.center);
RaycastHit hit;
bool isGrounded = Physics.BoxCast(boxCenter, boxHalfExtents, direction, out hit, orientation, maxDistance, groundLayerMask);
if (isGrounded)
{
// Check the surface normal
float slopeAngle = Vector3.Angle(hit.normal, Vector3.up);
// Allow jumping only if slope angle is within limit
if (slopeAngle <= 45)
{
return true;
}
}
return false;
}```
Sure, it's just pixels. Would probably be able to just construct a bunch of textures and store them in some static registry
Is this AI code by chance?
nope
i did a raycast before, then changed it to boxcast for an accurate raycasting
Your model should have absolutely no effect on the logic happening here. The capsule collider you have is likely just the same one as the 3d capsule, unless you see it as like a mesh collider or whatever the name was
yeah exactly, but strangely it works different
just a capsule collider
You should start debugging then and see at which point the logic is different in your code
Are you getting different capsule collider with it
its just different size in height and radius
nothing else
Or is the boxcast blocked by something within model
it shoudlnt, the model doesnt have its own colliders except the capsule collider i just set
A lot of the code you have is purely just defining variables. It should be pretty quick to just start debugging and seeing at which point exactly the code does something different.
Alright, I will do it now
That boxHalfExtents thing looks unnecessary to me though, not sure why you have your own groundCheckLengthOffset in there
Maybe your groundCheckLengthOffset doesn’t go well with different height you put
offset is set to 0, just put it for sake of it
i tried changing it to zero but no change
i guess i will debug more
the argument of boxcast needs extents
Tbh you could even just change this to capsule cast and use the actual capsule to determine the parameters. Boxcast might run into weird edge cases
Im not sure which is best. Im thinking to put a box collider for my player... What do u say?
I just know that spherecast/boxcast is better than simple raycast, but which to use?
None are better, they are situational
Your character is a capsule, so why use a box?
its a fbx model
I just thought box l would fit it better
like its a humanoid
with arms and legs
That's not what I was referring to. It's already made using a capsule collider. A capsule collider will cover the best area for your humanoid
I see... so what i should change is either debug the current boxcast to know whats happening.
Second, maybe use a capsule cast... right?
The corners of a box are further out than the edge of a capsule. Your player wont be able to move in a lot more scenarios, and rotation will be weird
I can imagine that. agreed
Literally just use a capsule cast, not sure where sphere cast is coming from
yeah I mean that... Made a typo xD
So, I'm struggling to understand why I am seeing jitter, I am moving a rigidbody (interpolation on) with forces in FixedUpdate and having the camera follow with Vector3.SmoothDamp in LateUpdate.
public class TestPhysics : MonoBehaviour
{
[SerializeField]
private float speed;
private Rigidbody rb;
private void Awake()
{
rb = GetComponent<Rigidbody>();
}
private void FixedUpdate()
{
rb.AddForce(Vector3.forward * speed * Time.deltaTime);
}
}
public class TestCameraController : MonoBehaviour
{
[SerializeField]
private Transform _targetTransform;
[SerializeField]
private Vector3 _offset;
[SerializeField]
private float _damping;
private Vector3 _currentVelocity;
void LateUpdate()
{
Vector3 targetPos = _targetTransform.position + _offset;
transform.position = Vector3.SmoothDamp(transform.position, targetPos, ref _currentVelocity, _damping);
transform.LookAt(_targetTransform);
}
}
SmoothDamp doesn't work when the target position moves
The easy solution is to use Cinemachine. Otherwise you'll have to come up with manual calculations to get the camera movement you like
I have the same problem with Cinemachine
it does, generally
im using it just fine
The issue with Cinemachine is easier to fix than this
is it jittering on its own, or is the camera jittering? (check the scene view)
Also don't multiply forces by deltatime (unrelated to this issue)
It's so that if the fixed timestep changes in the project settings that the speed value still applies the same force
Cinemachine has same problem
Force is already treated as “amount applied over time”. You don’t need to multiply deltatime
If you change the fixed time step though, then the speed modifier isn't the same as before. That's not the issue here, I'll remove it though
It does the opposite. If you multiply by deltatime and change the timestep, it'll change the force applied
With Time.deltaTime removed
Does someone know what can trigger this artefact in motion blur? It appears when you turn the camera a bit fast on only left and right edges of the screen. I am using unity 6 36f1 and latest urp version, here's my motion blur configuration
Does the issue happen if you just parent the camera to the sphere?
Also, I wonder if it has to do with your fps/frame time jumping like crazy.
Well no, because it is then in lockstep with the sphere. Same as if I set daming value to 0.
Also I don't know what's up with the crazy fps jumps. It's definitely the editor causing it, it is an HDRP project, but the scene basically has nothing in it
Use the profiler to troubleshoot performance.
I think it's a combo of damping and performance
Regardless though, I still see it when the fps is slightly higher than the fixed time step. It's something with the inspectors, idk if it is Unity 6 or whatever, but when it draws the inspector it tanks
*deltaTime is already applied internally for Force type AddForce
Okay thanks, yeah I removed it
It's not an issue of "higher/lower". It's an issue of it being unstable
So a follow camera just won't work if the framerate is unstable? I just don't get that
I'd confirm that it's an editor issue first. And if it is, test in a build
Many things would work weird with unstable framerate
That's why you usually have target framerate and vsync
Though, it's still just a guess. You should confirm it first.
I mean don't plenty of games do this though, like you want your camera movement to be in step with the fps? Like if I'm playing COD warzone and driving a car my framerate sure as shit not stable, but the camera movement is not jittery like that.
You could try updating it in fixed update then. Though I can't say for sure if that's gonna fix it.
Right, but then doesn't that mean the game is going to appear as if it is running at 50 fps of the physics loop?
since camera will only get moved at 50 fps?
No. The rendering is unrelated to where you move your camera
but camera movements will be at 50 fps
In normal situation it would cause slight jittering
but it's probably gonna be better than unstable framerate
Anyways, it's all speculations untill your confirm the assumption
Yeah I'm making an FPS counter now and will make a build shortly
is it possible to set unity to open new files in visual studio from the Assets folder, instead of solution view?
available views button shows the entire project folder instead of just assets:
(sorry for late reply) If the edges all had the same length, then yes, BFS would result in shortest paths. In general graphs with differing edge lengths/weights though, you need something more sophisticated. Well implemented Dijkstras algorithm isn't slower than BFS by lot, it only has logaritmic multiplier in the time complexity
If you don't have thousands and thousands of vertices and edges, the performance wouoldn't be an issue regardless
sorry im still a little confused of the "edges' length" here, so the line between 2 nodes is a edge and the path between 2 rooms is this edge? or is it the cost to walk 1 step on the path is the edge length. im thinking its the latter?
i think it would only make sense if it the latter
Solution: View -> Unity Project Explorer
How are you representing the dungeon in your code?
its tilemap, corridor first , generate the path by bunch of tiles in a straight lines, choose the end of the path as a potential room, so a room can be here or not, if not then path to next room is double or triple if failed again
Do you actually need this type of heatmap where every tilemap tile has their own distance or do you only need one distance per every room?
you know what i think i got it, it is latter
i believe it would be more confusing if continue lol
Hi, I am doing a capsule cast but somehow it isnt working. The isGrounded bool is always coming as false. Can anyone help me find whats wrong here?
Vector3 point1 = transform.position + capsule.center - new Vector3(0f, halfCylinderHeight, 0f);
Vector3 point2 = transform.position + capsule.center + new Vector3(0f, halfCylinderHeight, 0f);
isGrounded = Physics.CapsuleCast(point1, point2, capsule.radius, Vector3.down, out hit, 1f);```
So, it does seem to be an issue of inconsistent frame timings. In a build, if I set the target framerate to 80 there is no jitter, but if I uncap it then there is jitter although slightly less noticeable at higher framerates.
My brain is just struggling to understand this, because I thought that is the whole point of Time.deltaTime is to be framerate independent. I guess it does not apply to inconsistent framerates though?
You could write it down and calculate on paper if you want. I'm sure it'll make sense.
The core of the issue is related to the damping function that you're using.
Also, rb interpolation could be related theoretically, as it relies on consistent frame rate to interpolate between frames.
well the build I tested with is with cinemachine, so I'm assuming it is applying similar damping,
but yeah I think you are right. It is probably the implementation of rigidbody interpolation expeciting a consistent framerate
I mean it could be either, there's multiple ways to implement it. I thought you had the data in a graph data structure where each room was a node and connections between rooms were edges (like in the earlier drawings you originally showed) in which case the former would be what you need. If you want to do the search on the tilemap or similar 2d grid, BFS/floodfill should work
yes i didnt store what room is connect and the length between two when i gen, i could do that actually but i think dont need to
Probably.
Did you try disabling interpolation on the rb and seeing if had any effect?
I need help with my vr game, i get a build error.
UnityEditor.BuildPlayerWindow+BuildMethodException: Error building Player because scripts have compile errors in the editor
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002da] in <57a8ad0d1492436d8cfee9ba8e6618f8>:0
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <57a8ad0d1492436d8cfee9ba8e6618f8>:0
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
With cinemachine it does fix it, but not with my simple test camera controller. This is because the camera now updates in FixedUpdate when using cinemachine.
The error is pretty self-explanatory, you have compile errors in your scripts. You need to fix them in order to build your game
Check if there are other console errors aside this one
Btw one last thing I want to add. There are many ways to implement flood fill (check the flood fill wikipedia page for reference) most of which wouldn't give you the shortest path. It is specifically breadth first search (BFS) that you should be looking at
ok no worry i believe i will understand what i'll write in the script
Anyone has any idea why the GPU fans go crazy even in the main menu? The scene is not even that big compared to other maps
you're rendering a million triangles in your main menu
seems a bit odd
Note that the game will run as fast as possible if not given a framerate limit
'''cs
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float moveSpeed = 5f; // Speed at which the player moves
public float jumpForce = 7f; // Force applied when jumping
private Rigidbody2D rb; // Reference to the Rigidbody2D component
private bool isGrounded = false; // Check if the player is on the ground
public Transform groundCheck; // Ground check transform (position under the player)
public LayerMask groundLayer; // LayerMask to define what is considered ground
private void Start()
{
rb = GetComponent<Rigidbody2D>(); // Get Rigidbody2D component
}
private void Update()
{
// Handle Movement (Horizontal input, left/right movement)
float moveInput = Input.GetAxis("Horizontal");
rb.linearVelocity = new Vector2(moveInput * moveSpeed, rb.linearVelocity.y);
// Handle Jumping
if (Input.GetButtonDown("Jump") && isGrounded)
{
rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpForce); // Apply jump force
}
// Check if grounded using groundCheck position and a small radius
isGrounded = Physics2D.OverlapCircle(groundCheck.position, 0.1f, groundLayer);
}
} '''
You need to use three backticks
it's the lowercase tilde
```cs
like this
```
(i used backslashes to prevent the code block from being recognized)
So a V-SYNC should do the trick?
i dont understand
or an explicit framerate limit
I just slap a 120 fps limit on when the game boots up
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float moveSpeed = 5f; // Speed at which the player moves
public float jumpForce = 7f; // Force applied when jumping
private Rigidbody2D rb; // Reference to the Rigidbody2D component
private bool isGrounded = false; // Check if the player is on the ground
public Transform groundCheck; // Ground check transform (position under the player)
public LayerMask groundLayer; // LayerMask to define what is considered ground
private void Start()
{
rb = GetComponent<Rigidbody2D>(); // Get Rigidbody2D component
}
private void Update()
{
// Handle Movement (Horizontal input, left/right movement)
float moveInput = Input.GetAxis("Horizontal");
rb.linearVelocity = new Vector2(moveInput * moveSpeed, rb.linearVelocity.y);
// Handle Jumping
if (Input.GetButtonDown("Jump") && isGrounded)
{
rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpForce); // Apply jump force
}
// Check if grounded using groundCheck position and a small radius
isGrounded = Physics2D.OverlapCircle(groundCheck.position, 0.1f, groundLayer);
}
}
there we go
' and ` are different keys
theres the player script
What about the shadow
That's the one having the issue, right?
using System.Collections.Generic;
using UnityEngine;
public class ShadowController : MonoBehaviour
{
public Transform player; // Reference to the player’s transform
public float delay = 0.5f; // How delayed the shadow is
private Queue<Vector3> playerPositions; // Queue to store player’s positions
private bool isGrounded = false; // Check if the player is on the ground
public Transform shadowgroundCheck; // Ground check transform (position under the player)
public LayerMask shadowgroundLayer; // LayerMask to define what is considered ground
private void Start()
{
playerPositions = new Queue<Vector3>(); // Initialize the queue
}
private void Update()
{
// Store player positions over time
playerPositions.Enqueue(player.position);
// Delay the shadow movement by "delay" seconds
if (playerPositions.Count > Mathf.Round(delay / Time.fixedDeltaTime))
{
transform.position = playerPositions.Dequeue(); // Move shadow to the delayed position
}
// Check if grounded using groundCheck position and a small radius
isGrounded = Physics2D.OverlapCircle(shadowgroundCheck.position, 0.1f, shadowgroundLayer);
}
}
theres the shadow
Okay yeah that's teleporting. It's gonna ignore all colliders
how should i go about fixing it, im a complete begginer for coding
I'll give it a try, thank you.
what's the expected behavior once they desync? that the shadow receives the same inputs but delayed?
First, a question about what you're going for: do you want the shadow to follow the inputs of the player with a delay, or should it be the position with an offset
yes, the shadow is supposed to be a copy of the player but delayed so it looks like a shadow
im hoping to make it follow with a delay
so you would queue the inputs, not the positions
nah, queueing positions makes perfect sense
because the player doesn't respect shadow objects; its position doesn't include hitting shadow objects
(i think you may have missed context - see #💻┃unity-talk)
im gunna be honest im a complete beginner your gunna have to dumb it down a bit for me lol
although, keep in mind that Update is not consistent - it's based on framerate, so if you suddenly have lag, the shadow will then have lag after the player
So, if the shadow stands on a shadow only platform, the player moves away. Then the platform drops off the shadow somewhere far away, and the player stands still.
Does the shadow:
A) Also stand still, at a great distance from the player
B) Move to near the player to get back "in sync"
right now you're queuing the positions, which will make the shadow follow the player perfectly, even if there's shadow stuff in the way
if you want it to have separate collision (for shadow stuff), it shouldn't follow the player (or well, the player's position)
it should follow the player's actions instead, aka the input that you give
so it should receive the inputs separately, with the given delay, and then be simulated separately
sounds weird but i guess it should just sync up but not be able to clip through walls and stuff
hold on, so the shadow should have an ai of its own to try to get back to the player?
i guess
that's a lot more complicated
Okay, so, you still want it to try to move towards a queued position, and just be stopped by things in the way.
What you're gonna want to do is use the rigid body to move instead of the transform. To get the destination, you'll want to use Vector3.MoveTowards with the shadows current position and the players current position. Pass the result of that to RigidBody.MovePosition, and that will attempt to move the object towards the players location, but will stop if it hits something
do you think you could help me with that please?
Hey people, I need some help..
So I want to make a virtual pet simulator for Android and I want it to overlay other apps. I researched a bit online and I see that Unity doesn't support that type of rendering. Can I use unity to do that and if yes, how?
That's pretty much the whole script. The queue and everything aren't needed. Just a move towards passed to move position
I don't know if it's the right place to ask the question but if anyone knows about this then let me know :)
not a code question, try #📱┃mobile or maybe #💻┃unity-talk
I see.. thanks
That's what I did to fix it, since it made no sense to use coroutines if I don't need to use a waitfor
Asked it a while back but couldn’t think of anything better yet. What’s the best way to generate a mesh with submeshes without using nested lists?
Because I know it’s simple with just a Dictionary<Material, List<int>> where key is material and value is a list of triangle indices for this material
'```
public int CHANNEL = 1; // the DMX channel the M_Roll variable is on. All other variables will be on succeeding channels i. e. M_Roll_Fine on DMX channel (CHANNEL + 1)
public VRSL_ReadBackFunction VRSL_ReadBackFunction;
public int[] DMXInput = new int[512];
private int[] VarChannel = new int[33]; // creates an array of length of the number of channels! cannot be edited, used for internal code
void Start()
{
FoundMaterials = Rings_ShaderLink_Test2.materials;
// calculate channel addresses! this will define which DMX channels these variables use!
for (int i = 0; i < VarChannel.Length; i++)
{
VarChannel[i] = VarChannel[i]+i+CHANNEL-1;
}
for (int i = 0; i < VarChannel.Length; i++)
{
Debug.Log(VarChannel[i]);
}
}
void Update()
{
// CONNECTING THIS TO DMX
int[] DMXInput = VRSL_ReadBackFunction.dmxRawData; // ARRAY THIS SCRIPT USES FOR DMX, it is extracted from the VRSL_ReadBackFunction object that is linked in this object's script!
float M_Roll = DMXInput[VarChannel[0]];
float M_Roll_Fine = DMXInput[VarChannel[1]];
float Ring_R = DMXInput[(VarChannel[2])];
float Ring_G = DMXInput[(VarChannel[3])];
float Ring_B = DMXInput[(VarChannel[4])];
float Ring_Speed = DMXInput[(VarChannel[5])];
float L_Roll = DMXInput[VarChannel[6]];
float L_Roll_Fine = DMXInput[VarChannel[7]];
float L_Light_Pan = DMXInput[VarChannel[8]-64]; //BUG: L_Pan seems to react only to roll and not the actual pan for some bizzare reason
float L_Pan_Fine = DMXInput[(VarChannel[9])];
float L_Tilt = DMXInput[(VarChannel[10])];
float L_Tilt_Fine = DMXInput[(VarChannel[11])];
I am unsure whether this is the correct way of setting array values to other array values...
I am trying to set the floats to an array value that is in the position defined by another array value.
The entire script works properly, *except* for the value "L_Light_Pan", which appears to be overridden to be related to L_Roll for some reason...
I did post the part of the code that is related
How it should work is that the L_Light_Pan is set to a value in the DMXInput array (a 512 long array), whose position is defined as the value of the VarChannel array entry that is at the position 8.
Should I instead replace the [VarChannel[8] a-
.....
Ok...
I think I know whats happening here now...
The L_Light_Pan value is set to the DMXInput entry whose value is VarChannel[8] subtracted by 64, which happens to land on the L_Roll value of a different fixture
Yep...
My issue is now solved, a simple parethesis error caused this (and a negative array indicies error in two light fixtures)
Is there a way to get mobile swipe inputs in the Unity editor/for a dev environment? I got the input system working for multiple input types (keyboard, controller & mobile swiping) but I wanted to implement a deadzone for mobile inputs in order to discard accidental inputs, and for that using an input simulator won't work for that use-case
I remember back when I was in college (Unity 2019) I used "Unity Remote" but it seems like the android app for that hasn't been updated in a while.
So I don't know if that still works.
using LINQ results in allocations, yes
i mean, they don't really interact?
but that's not a unity thing
I use a fun little package called RefLinq in many places
It completely avoids allocations by not using IEnumerable
instead, you get a horrifically complicated struct type
not all LINQ works the same
i was more talking about supposed issues with linq and the GC not collecting it's trash?
stuff i stumbled onto online. if its not a problem i need to be aware of then - just wanted to know if theres substance to it
i mean, gc doesn't collect until it has to
discussions
well we can't verify or dispute any claims unless you give specific details
OP under the assumption that all LINQ functions allocate the same . Not all LINQ are heavy enough to notice much different
you're basically asking "is linq bad" here without any scope as to what aspect or severity you're referring to
yeah
Ofc you dont want to be slapping a heavy LINQ function in Update if you can avoid to.. stuff like that
https://www.reddit.com/r/Unity2D/comments/6kqk0b/i_wrote_a_brief_introduction_to_linq_for_unity/ i saw some concerns in this thread
ah reddit, the source of knowledge
nah i'm not using it in update. i know how linq works, i dont know fully how it works within unity
hence why i'm asking if theres any substance to it.
there's only one comment talking about memory here
They do go over that in the article, but they understate it. They say "it's OK, just don't use it every frame." What they fail to mention is that it can allocate a lot of memory. I can't remember the specifics but I had to remove LINQ from my code because it just allocated way too much memory for simple things.
oh man this is vague
but yes, there's a baseline amount of garbage, and then some operations are inherently more garbage-producing than others
indeed
i guess the specific question is. should i avoid linq entirely or no
no
No.
ok. thank you!
i dont know fully how it works within unity
it doesn't. there's no interaction. it works within mono, the runtime, and so does unity
It's one of the first things I look at when trying to reduce allocations, though
(hence RefLINQ above)
The readability that LINQ provides is very nice.
I used it a lot when gathering data for an AI system
most of the cost came from analyzing the data
most concerns there are about perf. as with anything perf related, don't overthink it until it becomes an issue, unless you're doing something that definitely needs perf, like making a million objects or something like that
so i didn't really care if it produced a bit of garbage
i'm pretty much using it for initialization of things
mainly because of readability yeah
you should especially not worry if it's only running once
someone if you know about this API keijiro
/
AICommand
I have an error nullreferenceexception
Any of you guys know how to work with secondary entrances and exits, from one scene to another, with different spawn points and exit points? Like Mario and DKC baically
Corgi's Retrovania maps barely helped
How did they implement it that made it barely help?
Brother what
LINQ is a bunch of extension methods that extend IEnumerable
It allocates absolutely nothing for most of its methods
Read the thread
Even better, it actively tries to avoid it by trying to find the best type
how clever
Yeah
It's all in the same scene
The main challenge here is that you can't just reference a door in another scene
But you can certainly reference an asset that uniquely identifies the door. You could create a ScriptableObject type (maybe call it Passage), then give each door its own Passage asset.
To go somewhere, you load a scene and look for a door with the appropriate Passage.
you could also use a string or integer or something
sounds interesting. I've discovered an issue with my player character's animator. I'll give it a shot when I can
I wrote source gen equivalent of it because struct linq types are scary (and have some limitiations) 
https://github.com/cathei/LinqGen
Neat!
Heh Goose metioned it in Honkperf already 
Though on CoreCLR Linq is getting very optimized, while Mono (thus Unity) one is less optimal
https://paste.mod.gg/nqvjyrqhlkvp/0 https://paste.mod.gg/rowmfjdoabey/0 So I have this massive system that works perfectly, except for a NullReferenceException error at line 20 from CombatInput when I run the game and idk how to solve it
A tool for sharing your source code with the world!
A tool for sharing your source code with the world!
All the variables are appropriately set in the inspector
Is that where you access .Instance? Ultimate solution would be not using singleton pattern
After removing the singleton thing and readapting it, I realized the null reference is actually from activePlayer which is already defined here
Do you mean when you access something within activePlayer?
yea, but now I've done some logs and it says its not null
uhh it suddenly started to work becuz I've defined the stuff in a different way for testing lol
sry for wasting ur time .-

yea, that was my reaction too when the system worked
I have more of a design question.
I currently am working on a first person hack and slash game. Right now i'm attempting to implement a blocking system where the player can block any incoming sword attacks. I plan to make it a bit more lenient by allowing attacks to be considered blocked as long as the weapon is within the frustum of the main camera. Would this be the correct approach? are there better methods
Initially I just want to check the enemies sword collider against the players sword collider but to me that's way less forgiving and technically challenging (especially since I would heavily rely on the animation)
actually this seems like more of a game design question so I might move it over there
animation can work, but if you were making something procedural when it comes to feedback then that becomes a little more complicated. Usually you'd have a few animations to lerp to if say an attack connects or is blocked otherwise.
the complexity and the fine tuning is what I would be worried about
plus for example, I wouldn't want the player to get hit if the enemy hits their feet. I feel like it should be considered blocked
but most games will do hitbox registration and callbacks during the animation itself
yeah, check out general fighting games. They give a lot of buffer room on attacks
So... I figured out the root of the jitter and it was a combination of inconsistent framerate, RigidBody interpolation, and the camera being updated in LateUpdate.
Now the simple "solution" (not good enough for me) is to just turn off RigidBody interpolation and move the camera in FixedUpdate as well. The major problem with this, is now the game appears like it is running at low framerate because the camera only moves each FixedUpdate.
The better solution is to actually interpolate the RigidBody between FixedUpdate calls ***and *** move the camera in FixedUpdate while also interpolating it between FixedUpdate calls. This allows for a smooth follow camera even at inconsistent framerates.
I'd ***really *** like to use Cinemachine, but I can't figure out how to interpolate it between FixedUpdate calls without fighting it 😦
So custom camera controller it is, sigh
Did it not work with the cinemachine camera updating in update/late update?
No with interpolation on the sphere and late update cinemachine / my cam, it is only smooth at consistent framerates
I don't think there is any way to get a smooth follow camera to work if you are moving an object in fixed update and moving the follow cam in late update, because they are essentially updating at different intervals
The only way I've found is to move both in fixed update and apply interpolation to both
I think the main issue is the rb interpolation that acts weirdly at inconsistent framerate.
Even with my custom interpolation, it behaves the same as regular rigidbody interpolation.
I feel like if you look at the object from a side with a static camera, you'll see it jittering as well
That is going to be hard to setup and test but I can try
Anyways, maybe just try getting a stable framerate instead of wasting time on this.
You really don't want to ship a game with unstable framerate.
I'm more curious in the theory of it right now, and that isn't realistic on PC, with the amount of hardware configurations / in game settings options
Of course it's realistic. I'm not telling you to keep 120 fps. Just telling you to not have it jump between 10 and 120
Using vsync or target frame rate should be enough to handle it.
Yeah I get that, I am curious about the side camera view, but after that I'll be moving on
If you're really curious about the underlying cause, do some logging, see the numbers at every frame and how they're changing. Think of what it means for the camera view. Step through the game frame by frame.
Okay so you're right, there is some jitter with a static side camera and inconsistent framerate. It is definitely not as noticeable, you gotta be like right up next to it, and I don't think that is an achieveable problem to solve. Whereas the follow camera at least can be allieviated by moving them both in fixed update and interpolating them between fixed updates. This means the camera and the object experience the jitter together in step.
If I'm understanding correctly, this essentially "moves" the jitter to the world and it appears as if the world is jittering, but since that applies to objects further out it makes it extremely less noticeable.
Well that's enough theory for today lol
Having an issue with my code - I've got a script that lets me rotate the bones of it's rig to turn the body. When I disable and enable the character, I can't do that anymore - it jitters and locks in place when I'm trying to rotate it. Just on its face is there anything that could be causing this that I can look into?
Is your rig playing an animation? Also are you rotating the bones in FixedUpdate or at another point?
@soft shard it is playing an animation, but it shouldn't have anything keyed to the bones that are being animated
I'm rotating them in update - I tried shifting them to fixed update and it didn't result in any change
EDIT: Nevermind, was some functions that weren't properly in fixed update - I pushed everything there related to this function + gravity and it appears to work fine, thank you @soft shard
!collab
:loudspeaker: Collaborating and Job Posting
We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• Collaboration & Jobs
Hi
A very quick question
I have a following function
But suddenly it dissapeared from button menu
Don't think it supports multiple arguments
because you added a second parameter
https://unity.huh.how/unity-events/method-requirements
or do this instead: https://unity.huh.how/unity-events/method-requirements-workaround
Thanks, i wonder why unity devs did it this way xd
Np, glad it worked out for you - I also just realized I made a mistake in typing FixedUpdate instead of LateUpdate, where FixedUpdate is the rate physics get updated and LateUpdate happens at the end of the frame after the animator finishes moving bones (in your case), though if FixedUpdate works for you, thats a interesting note
I am trying to use CapsuleCast so my player does ground check. But There are 3 problems I am facing:
1.) The debug.line shows the 2 points coming above player's head and never touching the ground
2.) The Player suddenly infinitely jumps if u spam if the maxDistance is set more than or equal to 3, and not less than that (I suspect this issue might be coming because of wrong point calculation)
3.) I also noticed that my debug.line red line isn't following where my player is going. Like if I move my player somewhere else, the capsule cast debug line is still at the previous position.
float radius = capsule.radius;
Vector3 capsuleCenter = transform.TransformPoint(capsule.center);
Vector3 point1 = transform.position + capsuleCenter - (transform.up * (capsule.height / 2 - capsule.radius)); // Bottom of the capsule
Vector3 point2 = transform.position + capsuleCenter + (transform.up * (capsule.height / 2 - capsule.radius)); // Top of the capsule
float maxDistance = 1f;
Debug.DrawLine(point1, point2, Color.red); // Draw the capsule
Debug.DrawRay(capsuleCenter, Vector3.down * maxDistance, Color.blue);
RaycastHit hit;
bool isGrounded = Physics.CapsuleCast(point1, point2, radius, Vector3.down, out hit, maxDistance, groundLayerMask);
I call this method when Player Jumps. But for debugging I am calling this method in Update() as well.
Excuse the phone screenshot, but I've been working on a building generator lately and so far I can populate a floor and 4 basic walls. A little magic from copilot and a TON of messing around, but hey I'm happy that I can at least do this.
Copilot got me to 70% working with this, and fooling around with my existing unity knowledge got me to here. Today I'm tackling rooms
I'm trying to use mouse to strafe camera sideways and up. It works when camera is straight angle but not if i tilt it:
Vector3 vec3 = (sensitivity * moveDelta.x) * mainCamera.right; Debug.DrawLine(mainCamera.position, mainCamera.position+vec3, Color.red, 4f); mainCamera.Translate(vec3);
the main camera is in root of the hierarchy, world tree
The debug line is absolutely showing correct direction vector, but translate doesn't follow same line
Like here the red lines go sideways by its rotation but camera moved up
hmm.. it works if i manually set position with variable 😒
what is wrong with translate?
Translate is local space by default
Are they not identical in case where it moves from root?
Your camera is tilted
hello, i have a weapon script with recoil that has Time.deltaTime implemented. But if i try at a low framerate, the weapon just shoots forwards to floating point errors. Heres my position changing scripts:
transform.position = transform.position+(posVelocity * Time.deltaTime);
and
transform.position += (((originalPosition-transform.position) * Time.deltaTime) * weaponReturnStrength);
What do you mean by “shoots forward to floating point error”?Regardless, you should normalize direction on latter
whats that mean?
also, i meant the weapons position on the z just goes really far really fast until it gets a floating point error
Are you talking about the first code or second code
not sure..
..Why not sure if you wrote the code
Second code is something you rather use Vector3.MoveTowards
Main problem is that you are not normalizing the direction
And also no checking for passing the destination
whats that mean..
You have google
i have unity discord
Good luck
I tried decals projector ( line and red color ) and somehow I got a window in screen space that do not render when in runtime, did I miss something ?
the decal projector will create some very weird results if your texture settings are wrong
It seems that it was caused by the Far clipping plane of the camera, ok now
Hello, I have some issues with connected anchor on hingejoint2D. Im making a rope and I dont know why when I move the rope the connected anchors go nuts and the rope go nuts with them
Do anyone have a tip to clamp the connected anchors ?
(I have autoConnectedAnchor on true)
Hii, i need an help with visual studio that cant connect with unity.
As you can see it wants to connect to a process.
IntelliJ doesnt work.
If i type "Rigidbody" i have this error
External Tools menu is not as usual, i dont have the option to regenerate the files
What should i do??
!vs
If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
also comment out any compile errors just incase when doing setup steps ^
Thank you so much i was going crazy
you got it working?
public class MoveCharacter : MonoBehaviour
{
public float walkspeed;
[SerializeField] private string walkAnimation;
Rigidbody rigid;
Animator PlayerAnim;
[SerializeField] private bool enemyInRange = false;
private Vector3 enemyDirection = Vector3.forward;
[SerializeField] private string attackAnim;
[SerializeField] private float attackMoveSpeed;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
rigid = GetComponent<Rigidbody>();
PlayerAnim = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
Walk(Vector3.forward);
if(enemyInRange)
{
AttackEnemy();
enemyInRange = false;
}
}
void Walk(Vector3 direction)
{
PlayerAnim.SetTrigger(walkAnimation);
transform.Translate(direction * walkspeed * Time.deltaTime);
//rigid.AddForce(direction * Time.deltaTime * walkspeed, ForceMode.Force);
}
void AttackEnemy()
{
PlayerAnim.SetTrigger(attackAnim);
transform.Translate(enemyDirection * Time.deltaTime * attackMoveSpeed);
}
}```
I have an issue where it doesn't continue the walk animation (still continues to move) after performing the AttackEnemy() function
How can we solve this without seeing the Animator state machine?
here you go
Ok and what trigger are you setting and which transition(s) is it used for?
attack enemy makes it fight
It doesn't look like there is any transition from the Fight state back to anything else
So it's no surprise it stays there
ohhhhh ok ty
private void Rotate()
{
if (isShooting)
{
Vector2 input = playerInput.UI.Point.ReadValue<Vector2>();
var ray = mainCamera.ScreenPointToRay(input);
if (Physics.Raycast(ray, out var hitInfo, 100f, layerMask, QueryTriggerInteraction.Ignore))
{
Debug.Log(hitInfo.transform.name);
Vector3 hitPosition = hitInfo.point;
hitPosition.y = transform.position.y;
Vector3 direction = (hitPosition - transform.position).normalized;
direction.y = 0;
transform.forward = direction;
}
}
}
hey guys i got this raycast and a player with a gun, wherever i shoot the player rotates towards the mouse position
my problem comes when the enemy has trigger colliders, for some reason the player doesnt rotate towards the enemy and completely ignores that area, could anyone help?
I mean
seems pretty obvious, you're passing this in.
so your raycast will ignore trigger colliders
i did try with .Collide but the problem persists
you would have to show the code in that case, and the layer mask you're using and the object you're trying to hit
with Collide, it will hit triggers.
I've got this weird bug where the player starts jittering when it reaches its Max Slope Angle
you would have to show the code...
This is my Grounded Check code
Also I think it's a major issue that you have a "static" Rigidbody that is rotating
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
please share your code in a readable way
Ohh srry
Use Scriptbin to share your code with others quickly and easily.
This is just the Check Grounded part of the script
I can upload the whole Custom Character Controller but I felt that would be overwhelming
I think seeing the whole script would be much better
Use Scriptbin to share your code with others quickly and easily.
but I think this is pretty cooked:
Vector2 Origin = (Vector2)GroundCheckPoint.position + new Vector2(xOffset, 0);```
even if your object is rotated you're only starting the rays along the world horizontal axis
so on a steep slope some of them are probably missing?
Oh yeah so I should instead do transform.right * xOffset
transform.rotation = Quaternion.Lerp(
transform.rotation,
TargetRot,
RotSmoothTime * Time.deltaTime
);```
you seem to be rotating your Rigidbody directly via its Transform
that's going to cause all kinds of problems
possibly including the jittering
I tried to use RB.MoveRotation
it needs to be rotated via the RB
But I wasn't sure how to use that with Lerping
the lerping is irrelevant
transform.rotation = newRotation;```
vs
```cs
rb.MoveRotation(newRotation);```
they both just take the new rotation
Oh so can I just put the Lerp as a parameter?
the lerping goes into how you're calculating what newRotation is
it doesn't matter to the actual assignment
Ohh KK
RB2D rotation is a float though
not a Quaternion
so you'd be just dealing with the angle
not a Quaternion
Just use the z part
no
don't use a Quaternion at all
you cannot read individual parts of a Quaternion - pretend they don't exist
Ahhh so it does. That's nice - that's new for Unity 6
didn't know about it
i'm getting some mixed info on google if i should use destructors for custom classes that contain subobjects of also custom classes (non-gameobject or other unity types)
Use destructors for what purpose exactly?
say it's a star system that has planets, when you destroy(star), what will happen to planets?
it's a data class
Destroy is irrelevant when it comes to C# objects
Destroy destroys the C++ unmanaged half of Unity objects
C# objects go away automatically when they are no longer referenced by anything else via the garbage collector
ok
well, there are child objects that refer their childs
lets hope it's smart enough then :p
WDYM by "child object"
there is no such concept in C#
there are only objects have references to other objects
Class A->B->C... refA = null;
what does "Class A->B->C" mean
is this an inheritance hierarchy? A bunch of things referencing each other?
yes like tree
I asked two separate possibilities there so I don't know which one you're saying yes to
If your object no longer has anything referencing it, it will be deleted by the garbage collector
you don't have to clean up objects in C# generally
destructors don't do that anyway - they give you an opportunity to clean up other things such as file handles or network connections
things that aren't C# objects.
private void RotateTurret(Transform rotPoint, Transform target, float maxRotationAngle, float rotationSpeed)
{
Debug.Log("Rotating turret");
Vector3 targetDirection = target.position - rotPoint.position; // Direction to target
targetDirection.y = 0; // Keep rotation on the horizontal plane
// Get the absolute world-space angle of the target
float targetAngle = Mathf.Atan2(targetDirection.x, targetDirection.z) * Mathf.Rad2Deg;
// Get the turret base's forward angle (starting rotation)
float baseAngle = rotPoint.parent.eulerAngles.y;
// Compute relative angle
float relativeAngle = Mathf.DeltaAngle(baseAngle, targetAngle);
// Clamp relative rotation within max left/right limits
float clampedAngle = Mathf.Clamp(relativeAngle, -maxRotationAngle, maxRotationAngle);
// Compute final turret angle (absolute world rotation)
float desiredAngle = baseAngle + clampedAngle;
// Rotate turret at a constant speed
float newAngle = Mathf.MoveTowardsAngle(rotPoint.eulerAngles.y, desiredAngle, rotationSpeed * Time.deltaTime);
// Apply rotation
rotPoint.rotation = Quaternion.Euler(0, newAngle, 0);
}
any reason why my turret still decides to take the short route outside of the clamp?
those comments 
yeah im really stuck on this
so i asked gpt
but like i expected, still some balony
what was the original problem ?
Eliminate all of this from your code:
rotPoint.parent.eulerAngles.y;```
```cs
rotPoint.eulerAngles.y```
reading euler angles back from a Transform and doing logic based on them is always a bad idea
instead, store your own variable for this y rotation
and drive the rotation from your variable
reading euler angles back from the transform is not reliable

Euler angles also cannot be reliably read in isolation.
the Y means nothing without the x and the z
do i use SignedAngle for my solution?
looks good from what i see
private void RotateTurret(Transform rotPoint, Transform target, float maxRotationAngle, float rotationSpeed)
{
Vector3 targetDirection = target.position - rotPoint.position;
targetDirection.y = 0;
Vector3 baseForward = rotPoint.parent.forward;
float angleToTarget = Vector3.SignedAngle(baseForward, targetDirection, Vector3.up);
float clampedAngle = Mathf.Clamp(angleToTarget, -maxRotationAngle, maxRotationAngle);
Quaternion desiredRotation = Quaternion.Euler(0, rotPoint.parent.eulerAngles.y + clampedAngle, 0);
rotPoint.rotation = Quaternion.RotateTowards(rotPoint.rotation, desiredRotation, rotationSpeed * Time.deltaTime);
}
so... this does make the clamping work, but when the target is closer to the other side, the turret takes the shortcut.
how would i approach it going the long route so it doesnt clip in the ship
RotateTowards always takes the shortest path
again use your own vartiable here
then you can do logic on it
Can someone recommend me a video or sth for NavMesh Hiding AI. https://www.youtube.com/watch?v=t9e2XBQY4Og&t=836s this tutorial isnt working for me so by chance someone even could help me with this
Learn how to make NavMeshAgents find valid cover spots from another target object. In this video we'll specifically use a Player, but this can be applied to hide from any object - a grenade for example. Together we'll create a configurable script that allows us to refine which objects are valid to hide behind and exclude those that are not.
We'...
it works. you most likely didn't set it up correctly
I've used it before
Someone tell me why I cant move while holding my mouse down with W A D
ITS NOT
Sounds unconvincing
how can i fix
prove it
Imagine if you asked a plumber to fix your sink without letting him look at the sink.
okay well can you help
weol what code, I am making a VR game
The code that isn't working properly
idk whats not workin'
probably the one that is supposed to make it move
why did you post in a code channel then
Maybe start out with that? And you posted in the code channel?
Debug.Log($"Ball color is {rend.material.GetColor(Color1)}, projectile color is {p.Color}");
Ball color is RGBA(0.761, 0.223, 0.223, 1.000), projectile color is RGBA(0.761, 0.224, 0.224, 1.000)
In inspector they both have same rgba and hex. How is that possible?
floating point precision shiz
Your material color channels are probably only stored with 8 bits - meaning 256 possible values. A difference of 1/1000 is not significant
Hmm, okay, thank you all. Then what would be the best way to compare it? Round the floats?
what is the point of comparing the colors?
what ar eyou comparing thenm for?
What's the end goal
everyone: WHY
Ahah, basically colors are generated in runtime, when projectile has same color as the wall something happens
real answer, add numbers up, divide by 3 and if its less than some tiny number then yay are super similar!
basically dont try to check if it exactly matches but if its very close
why not give them some other more concrete identifier that can be compared more precisely?
would be better to just use like an int or an enum or something
all my homies love enums
enums, so hot right now.
If you genuinely need to test how close the ball's color is to the wall's color, compare their hues
However, you probably don't actually want that (:
I could truly use someones help with this bug I am getting. I want it so that, if my player is in the range of enemy's attack. My enemy will stop looking at its next path point and going to it and just face my player. The issue, is that it is freaking out and spam turning left and right and Idk what to do to fix this issue,
Enemy Script:
https://paste.mod.gg/neqqjdiiaves/0
Cultist enemy Script:
https://paste.mod.gg/vesakojxnuub/0
A tool for sharing your source code with the world!
A tool for sharing your source code with the world!
Start by debugging your code, adding log statements to see which parts are running and when and double check your assumptions about your code
I'd say the main issue is that you define a specific behavior right in update. You should take it out into a separate method that you can override.
Also, your approach is gonna be very limiting. Unless your ai is not gonna get any more complicated than that, I'd recommend looking into state machines, behaviour tree or maybe some more sophisticated ai frameworks, like GOAP, utility ai, etc...
my enemy isnt getting more complicated. Its just moving left and right, sees enemy, attack, repeat.
I modified a scriptable object and have no errors in my code, yet the inspector view has not updated, even restarted unity + ide. Anyone had this before?
Are Triggerable and Experience marked with [Serializable]?
Yes, well Triggerable is an interface, but I have an inspector thing for that, it was working before so I don't suspect it's the issue.
What do you mean?
Yellow squiggly lines
Oh nothing bad, 1sec.
I have an inspector thing for that
and are you using it for those specific fields?
Interface can’t be used with SerializeField, and it’s convention to put I prefix to name
Ah wait squiggly lines yeah
Was missing this on "onAccept" and "onDeny"
[SerializeReference, SubclassSelector]
guys im so done with this godforsaken turret rotating function. nothing works, there are no explanations for the reverse rotating when the target could be reached from the other side. no YT vids, no forums, GPT is giving me sticky balls. its like no one has needed what i need and its killing me!!!!
It was saying I was missing _ for private cause they weren't serialized (I assumed)
thanks!
Make sure you rename it to ITriggerable 👀
If you need help, you should provide a better explanation(possibly with screenshots or videos), and the relevant code.
Have you tried studying up on quarternions?
If you understand how those work, then you'll understand how to make the turret rotate how you want
There's a nice editor extension for it I've been using
Yeah, you can use SerializeReference which works differently
private void RotateTurret(Transform rotPoint, Transform target, float maxRotationAngle, float rotationSpeed)
{
}
i have a function that should
- rotate the turret towards the target
- clamp the rotation within (-)maxangle
- if the targetRot is within the opposite clamp, turn around (the long way)
after countless iterations i only got 1 and 2 to work. with and without stuff like RotateTowards etc.
im actively doing it but a lot of stuff im seeing glosses over it and most of it extends to "Quaternions return different values than euler"
Honestly, I'd use direction vectors as much as possible instead of angles and quaternions.
You can easily compare directions with dot product. Negative dot product would mean that the directions are "opposite"
Clamping angles can be ambiguous because angles wrap around
Show what you tried?
I'd probably use Vector3.SignedAngle to get the Y (and X?) target angles for your turret
I wouldn't look at anything about quaternions in a gamedev context. You should learn the core principles of what they are, unity has absolutely no bearing on what a quaternion is
I disagree, you don't need to know how quaternions work
Just learn to use the helper functions in unity
You mean knowing what the x, y, z, w components do?
What they are and how they work
Knowing how to actually write the function is absolutely the right thing to need to know, but if you don't understand (and not even to an overly advanced degree) what you're working with, it's going to make it harder to understand how to head towards a greater goal
Holy crap somebody knows how a quarternion works? How tf that’s insane
i have the visual representaion of that in my mind
I just accepted it stores a rotation and try not to think about it too hard
Should've added to this, how they work internally*
I don't think anyone actually knows what a quaternion truly is 100%, they were likely invented as a cruel practical joke
I never had to worry about that stuff. Just know that they represent rotations, they can be combined with * (order matters), they can rotate vectors with *, and unity has a lot of helpers like FromToRotation, AngleAxis, LookRotation
quaternions are black magic that only mathemagicians truly understand
Yea i tried that and it is sadly just not working. My facing thing is either overriding each other or just completely fucking broken when you add 2 things. It continously thinks it needs to flip when my player is to the left of the enemy, but thinks its facing perfectly when the player is to the right which is isnt.
here if you want the scripts:
Enemy:
https://paste.mod.gg/dskmaikplryf/0
Cultist enemy:
https://paste.mod.gg/iztsldjtjzdn/0
(i am losing my freaking mind fr)
private void RotateTurret(Transform rotPoint, Transform target, float maxRotationAngle, float rotationSpeed)
{
Vector3 targetDirection = target.position - rotPoint.position;
targetDirection.y = 0;
Vector3 baseForward = rotPoint.parent.forward;
float angleToTarget = Vector3.SignedAngle(baseForward, targetDirection, Vector3.up);
float clampedAngle = Mathf.Clamp(angleToTarget, -maxRotationAngle, maxRotationAngle);
float desiredWorldAngle = rotPoint.parent.eulerAngles.y + clampedAngle;
float currentAngle = rotPoint.eulerAngles.y;
// WRAAAGH IT STILL SHOTCUTIHGUI RGBGFYHEGF
if (Mathf.Abs(Mathf.DeltaAngle(currentAngle, desiredWorldAngle)) > maxRotationAngle)
{
desiredWorldAngle = (angleToTarget < 0) ?
rotPoint.parent.eulerAngles.y - maxRotationAngle :
rotPoint.parent.eulerAngles.y + maxRotationAngle;
}
float newAngle = Mathf.MoveTowardsAngle(currentAngle, desiredWorldAngle, rotationSpeed * Time.deltaTime);
rotPoint.rotation = Quaternion.Euler(0, newAngle, 0);
}
this was the closest ive come, but it still takes the shortcut
i delete the if() and nothing would change
FYI, the vectors you put into SignedAngle should be first projected on the normal plane
I learned this rather recently (thanks vertx)
var projectedBaseFwd = Vector3.ProjectOnPlane(baseForward, Vector3.up);
var projectedTargetDir = Vector3.ProjectOnPlane(baseForward, Vector3.up);
float angleToTarget = Vector3.SignedAngle(projectedBaseFwd, projectedTargetDir, Vector3.up);```
Or in this case since it's just the up vector, you could set their Y to zero instead of projectonplane
i see
thats good to know
any other important small letters ive yet to discover (it still shortcuts)
OHOHOHOH i got something
// abovr is currentangle
float speed = rotationSpeed * Time.deltaTime;
if(Mathf.Abs(clampedAngle) > maxRotationAngle * 0.9f)
{
speed = -speed;
}
float newAngle = Mathf.MoveTowardsAngle(currentAngle, desiredWorldAngle, speed);
its
going to other way
Did you debug as you've been told?
but not entirely
MoveTowardsAngle would take shortest path iirc
And negative delta is not supported
yeah someone said that before but like... there were no other souces that used something else
its literally Towards() everywhere
yea, the debug is telling me that it doesnt need to flip the sprite when im to the right (when it needs to) and that it constantly flipping sprites when im to left. Im thinking of just trying to recode it from scratch
You may want to use non-Angle version if you know direction it should rotate
Just make sure you +- 360 correctly for the direction
I can't read the code from that site on mobile. The text gets reset whenever I try to scroll. If you can upload it to a different one, that would help.
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
hope this works
I barely see any debugs in your code. And just taking the movement logic out of update is not gonna change anything. You're still calling that method in the base class update every frame, and you call the base class update in the extending class, so the move along waypoints logic would run all the time, even when it's supposed to engage in combat.
If it's telling you that it doesn't need to flip the sprite when it should, then debug/investigate why it tells you that. There must be some condition that makes it act like that.
rotPoint.localEulerAngles = new Vector3(0, Mathf.Clamp(rotPoint.localEulerAngles.y, -maxRotationAngle, maxRotationAngle), 0);
why this snappy behaviour?
this code seem to not only clamp but also make the turret turn around
(added after rotateAround)
float step = rotationSpeed * Time.deltaTime;
if(IsInRange(remainingAngle, 1.2f))
{
step = 0;
}
if (angleToTarget < 0)
{
step = -rotationSpeed * Time.deltaTime;
}
rotPoint.RotateAround(rotPoint.position, Vector3.up, step);
rotPoint.localEulerAngles = new Vector3(0, Mathf.Clamp(rotPoint.localEulerAngles.y, -maxRotationAngle, maxRotationAngle), 0);
Because eulerAngles.y will be in 0-360 range
https://github.com/cathei/RotationMath/blob/main/Packages/com.cathei.rotationmath/Runtime/RotationMath.cs
I got general angle normalizing/clamping logic if that helps
I am currently working on a prototype project for implementing a base-skeleton structure for a game. Here I have coded two picking-up mechanisms. There seems to be an issue here. If any one is interested to help me, feel free to ping me on my DM.
https://cdn.discordapp.com/attachments/497872424281440267/1340872314182697031/2025-02-17_07-17-4211.mp4?ex=67b3f027&is=67b29ea7&hm=79122a2262a5b3ee78585a21faa29dc9e87cf934c48d507606e033a434fc8fc4&
this concludes my day
real 
some system design questions tho , to ingame forms and dialogs
some games will have multiple steps of dialogs right? like steps 1 require u to fill in an input field for bday, step 2 will be nickname, step 3 will be username/email....etc
but when u think about it, those "input fields" are mostly the same right?
so i was trying a new approach, instead of spawning them under certain parents in groups, i will spawn them all without parents at first and group them in inspector fields
so when i want to move to next step, i just disable the one and enable the new one
maybe i can spawn and have less objects in game scene in this way
or u guys still prefer spawning them in groups with few extra objects?
only cases where I will fully populate some data struct is if it's a predetermined grid / array
this seems to mostly be preference too so what ever you prefer honestly
the only downside of serializing everything directly is if serialization breaks then you're having to manually do it again
I have had visual studio code for a while and have had this error for awhile and I just tried to get rid of it by installing the SDK and when I did I restarted my pc like the video said to do and I open it up and the error is still there I don't know how to get rid of it because I have the SDK installed i don't know what it wants could someone help me also I have uninstalled and installed C# dev kit to see if that helped it didn't
go to console dotnet --list-sdks show screenshot
dw i have measures on those cases, but yeah its about rebuilding when that comes,
in the debug console or terminal
in terminal
you typed it wrong
oh what was i suppose to put sorry
- dotnet list-sdks
+ dotnet --list-sdks
this is how i did it but nothing showed up
Then you have none installed
what about dotnet --info
but i do have them installed because if i open up the file to download it it shows the options of repart uninstall or close
did you restart pc when you installed?
If you had sdks installed it would have showed them with that command
yes but ill try again with the restart
Alternatively follow the folder specified in my case and see if they exist for you. Otherwise you should look into reinstalling them.
Hi there, anything I should know on limitations to store data on Android and iOS devices ? We come from years of PC dev and I'm just thinking of my progression layer as we started our first development for mobile
Alright looks like I don't have to care much, thanks !
i just restarted my pc I still have the error should i try to repair it or uninstall it and reinstall it and then restart my pc again
I just looked at my output tab and it's howing this so does this mean I have to install version 6.0.0
if i would have the download version 6.0.0 would i have to download the ASP .NET Core Runtime 6.0.0, the .NET Desktop Runtime 6.0.0, the .NET Runtime 6.0.0, or would I have to download the SDK 6.0.100
I think I found the problem but idk I found out that I downloaded the x64 version of the sdk and not the x86 version
I fixed it, it was because I downloaded the x64 version and not the x86 version
if u looked at the reply, u will notice some of those "parts" can be reused across different steps(groups) , the collection of the mapper must have duplicates
so, in order to refresh the UI correctly, i cannot just disable and enable components based on the step, i need to check whether the components will be used on other steps, and ignore it , otherwise the component will always be disabled
which is why the refresh function will be like this :
public void RefreshStepObj(int currentStep)
{
List<GameObject> objToIgnore = new();
foreach (GameObject element in Steps[currentStep].Objects)
{
for (int i = 0; i < Steps.Count; i++)
{
foreach (GameObject element2 in Steps[i].Objects)
{
if (i == currentStep)
{
continue;
}
if (element == element2)
{
objToIgnore.Add(element);
}
}
}
}
for (int i = 0; i < Steps.Count; i++)
{
foreach (GameObject values in Steps[i].Objects)
{
if (objToIgnore.Contains(values))
{
values.SetActive(true);
continue;
}
values.SetActive(i == currentStep);
}
}
}```
it works, but as u see theres many looping going on lol, i wonder if i can simplify it more
If you just want to make it "prettier" visually, you can always use Linq filtering, sorting, finding to create your objtoignore array
but the iteration has nothing wrong or its decent enough in efficiency?
Depends on the counts of execution, but in general,. no, its not doing much. Checking two values and filtering it
there wont be more than 10 steps and 50 gameobjects in total
Nah, I mean, if you fire that function in Update() , its another story (probably) than once everywhile
they are all event based, or call based, no update/fixedupdate involved in any of it
only when pressing buttons
i guess its enough lol
ty 👍
Only thing that might be weird is the second for loop. you are checking if its part of ObjToIgnore and set it active then, otherwise you still set it active if its currentstep?
the first loop is to find out which UI elements of that step are used in somewhere else too
the second part of the loop is the enable/disable part
basically its the logic of "re-disable everything" -> "enable only some of it i want"
so you could just do
values.SetActive(i == currentStep || objToIgnore.Contains(values));
okay, by looking at it at bit more, it might be simplified more
But it works and wont cause any harm. Do not have time to dig into it more, sorry, but you could def. make it more "elegant". But its such a small impact, if at all, so it could be a refactor for later
nah if its decent enough i will leave it as it is
its just weird going through the current step and than again through all and again through all steps. I am sure, it could be simplified. But as you say, its decent enough
the script using that thing is a hybrid one, it can be used as editor GUI scripts on inspector and called during runtime
but 95% of time it will be editor scripts
Ah, got it. so you mean, scripts running in editmode rather than editor scripts per say
mostly in editor mode
90% part of it is this thing
u put in the type (enum) u want to spawn at "spawning element" , and press rebuild UI, then it will spawn out the UI u want
ahh, got it. So you have like a content template that you generate from with that enum, cool
if ur dialog doesnt have multiple steps, it will map automatically, if it has multiple steps, ofc everything will be manual
map objects urself
yeah
the most annoying part is scroll rect
why?
not very annoying tho, but u need another pretty similar scripts for it
which is the one im working on, should be fine lol
the first thing i gonna ban is to allow scroll rect inside scroll rect lol
no way i can let u do that, even its possible
the alignment gonna become weird
I mean, it can make sense to have scrollable horizontals in verticals for lists/shops/whatever
in that case i just gonna make element bigger and longer, enabling horizontal scrolls on parent 💩
its certainly doable to have a scroll view in another but it helps when you dont mix the scroll directions
you have to often do stuff to prevent scrolling on the parent when interacting with a child one.
is there an option to make Build profile show XR Plug-in Management? (currently using Unity6 25f1, and XR ToolKit 3.0.5)
I want to create a profile for Meta | Pico (requires different checkmarks on platform choice)
Has anyone else noticed that since 6000.0.38, it's not taking 20 minutes between each run to reload domains anymore? 😍
What do you think about Dictionary<key Dictionary<key, value>>?
wdym "what do you think about" if you have an actual question then ask that
Uhh I mean
It depends on the circumstance I guess??
I personally don't see why you would ever need this
if that kind of data structure was needed i'd rather define a struct containing a dictionary to use as the value, just for readability
Instead of Dictionary<K1, Dictionary<K2, V>> you can also do Dictionary<(K1, K2), V>. The former does have the advantage that you can use all values under one K1 like a dictionary though.
But yeah, I don't think I've had a situation where I need a data structure like this.
Reading the values of ContactPoint2D.normalImpulse and i saw 188,461.7.
When all i'm doing is moving left and right on top of boxes.
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
I've got a basic movement system in place right now that uses a Speed Difference system to ensure tight turns. However, this messes up transient forces like Jump Pads and other instantaneous effects. I'm looking to separate the force from the Run function into a Vector2 Player Vel, and calculate it separately.
If it was a ForceMode2D.Impulse it would be really easy, as I can just add the PlayerVel to the RB.linearVel every Update. However, it is a ForceMode2D.Force
Use Scriptbin to share your code with others quickly and easily.
Like how would I make the velocity force decay over time
Hi all, what would the best channel be to discuss general system architecture?
unlkess you mean code architecture
Thanks
then... here?
I do, but more its for a larger system
Ill post here and then move it if its not in the right section.
i find it really unclear what you're asking. this message here seems to be unrelated to your one above
to make a vector "decay" over time you could just MoveTowards the zero vector
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Vector3.MoveTowards.html
in relation to the first part of your question, I think you'd have an easier time changing this logic so you aren't actually adding force to the player. Keep track of separate vectors for the different kinds of movement you'll have and then add them all to set that as the players velocity every fixed update
Yeah the second part of your statement is exactly what I'm trying to do
Does the ForceMode change the way I add them to the velocity
Because I know Impulse is basically the same as directly adding it, but I'm not too sure about Force
the difference would be when you use them, force is meant to be applied overtime so this is something you would do every fixed update. impulse is meant to be instant like one time things. The rigidbody doesnt care if it was force or impulse
Though if you're gonna keep track of vectors yourself, its not like you'd use the ForceMode
Doesn't look like a code related question
Where can i put it :P
Thank you srry
Nw's I'll move it to the other channel then.
okay thanks, and sorry
hey guys question awake and the start are they called on a diffent frame?
they can be
depends on the circumstances
for example if you instantiate an object in LateUpdate, I would guess (need to test) that its Start won't run until the next frame.
if script is Enabled = false
Awake will run
Start will not run until enabled
for example
Yeah but is this done In 2 frames
What's the context of this question? What are you trying to do?
well it was just a discussion with my collegue about if it happens onn 2 frames or one frame
in theory it should be in one frame
Not quite. Correct in that Awake happens first, but the difference is Awake doesn't actually use the frame timing at all. Awake can basically "interrupt" the currently processing frame, while Start will happen before the first full frame the object exists for. So if something's spawned in on a specific frame, awake will run, the rest of that frame will run, then Start will run before the next update tick
it really depends. Start works in a funny way. You can imagine code in Unity's engine like:
void UpdateLoop() {
foreach (Component c in updatableComponents) {
if (!StartHasRunFor(c)) c.Start();
c.Update();
}
}```
It works like this for all the "update" style functions
Awake works more like a constructor of the object though, start is like the single time version of Update. It depends on the Monobehavior activity
Maybe here this makes more sense
Im making a "voxel" type game, aka unity cubes and i want to have the sides of the blocks that toches another block to be disabled and not be rendered, how do i go about this, i looked into voxels, but i dont think that matches for the game im making, its not like minecraft, i dont have world generation, the world is player made with cubes and limited to a 200x200 space
If anyone has an idea to make that more optimized like disabling renderers of covered cubes or disabling faces of overlapping faces and stuff like that or if i should go for voxels, but without chunking
Seems like you would use the same techniques as any minecraft game though
Thats absolutly not my thing, i make games and even multiplayer, but never worked with so many gameobjects (cubes)....
These cubes are killing me (and my pc)
for example - using a single GO per cube is probably not a good idea.
So i would do voxels
wdym by "do voxels"?
Oh god how the f do i network that
networking and rendering seem like completely unrelated issues
Not gameobjects, but a voxel engine ?
Like with minecraft and stuff
I'm saying if you look up guiides for like "how to do minecraft in Unity" you can use many of the same techniques
the way they render it is to generate a mesh dynamically
for a whole chunk
Yes that is what voxel engines are
I tried to avoid that as its hella complex and sigh
whats a voxel engine?
though I'd disagree with you on the terminology
voxel systeM sure, not an engine
a voxel engine would be a completely separate thing from Unity
I can't say I've watched this particular tutorial series but it looks pretty thorough
it probably has a lot of stuff you don't need though
its like saying "The Pixel engine"
I wanted to keep one cube one object and just disable the renderer or sides from the not visible stuff
So its easier to network
As networking a gameobject is automatic mostly, but networking the voxels is gonna be a pain in the arse

I'm not really sure I understand what one has to do with another
Any other idea where i can keep using gameobjects ? Like this ?
"networking the voxcels" wdym
So if a player places something that the other players see that ?
networking a GameObject is automatic sure if you attach a NetworkObject to every single one. With that many objects that will be a disaster
Yes, the player would send an RPC to the server saying "place 1 dirt block at x, y, z".
Then the server updates the voxel array and broadcasts that the block was placed
No it wont, it depends on the networking solution, ngo will implode, but the one im using is fairly good in that way as it only sends data if its changed
it's not that complicated and it's very little data
you can do that same thing. Very easy
Ok that sounds fairly doable is it really that easy ?
yes it's really that easy
- when client joins, send them a snapshot of the whole voxel array
- send them an update any time a block is added or removed
the client will always have an up to date array
as long as your network framework guarantees in-order RPCs
Voxels looks like wizard fuckery to me cuz i have not much clue about rendering and editing meshrs
No clue actually
Ok thanks for the heads up, i will look into voxels

Any tutorial or article you can recommend ?
Cuz i mostly find minecraft garbage thats based on chunking n stuff
@leaden ice
you don't need to ping me
Sorry wont do that again
Any minecraft tutorial would probably do. Just pretend your whole world is a single chunk
everything else is the same
Unity doesn't have built in scaling for resolutions????
You have to write it yourself? What??
in what sense?
It definitely scales automatically in general
Let's say my game is 320x640
I need the resolution of the game world to remain that
And not change
Sometimes game worlds are not related to window size
the game world in Unity is not related to window size
For example, look at Celeste
The game resolution is 320*640 iirc , and the window just scales that to the middle of the screen
Not sure I follow aht you're talking about
but distances in the game world in Unity are not related to the number of pixels being used to render them on the screen
Okay let me put it like this
I need a fixed canvas size
That cannot change
Even if the window is resized
One option is to render the game to a Render Texture at a fixed resolution
and display it on a RawImage
Celeste gets bigger too, it fills the whole screen, but the game res stays at that size
yes thats exactly what i want
yeahhh that sux kinda
unity should have that built into the engine
It's not really a common thing
almost every pixel art game needs to do that 
No barly anyone needs that, just use pixel perfect
Thanks right on time
lemme seee
thankies
im rewriting flappy bird 1:1 and i have the game assets, but theyre fixed sizes
i rlly wanna play flappy bird in 2025 without all the bullcrap from the play store
Thats why its important to ask how to archive something, not how do i do something specific, incase the specific thing is the wrong approach
what did they do ?
it doesnt exist 
Sorry am new here can anyone help me on how to start creating my own game using unity game engine?
the creator took it down cos he kept getting death hreats
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
i already built it 1:1 in raylib, but i couldnt run it on mobile
so it ended up being completely useless
Apart from youtube where again
i just linked you
click the link
wow thats effd
that was like in 2014 how did you just find out 😭
I live under a rock
tbh using unity makes me feel like im gonna be judged
Pls can I make new friends here I have none😩 😩
the internet is a really stupid place
this isn't really a casual chit chat discord tbh
fr, IM NOT A BEGINNER JUST BC I USE A POPULAR ENGINE
ive been a programmer for like 3 years 
silly to get stigma over software
people are dum
Hmm can we be friends
i already have all my imaginary friends i'm good
also please read #📖┃code-of-conduct
yeah its strange, its like being upset about a hammer..
Ok - code architecture question - I can't seem to figure out how to efficiently store this information. Let's say you have a 2d "canvas" of sorts. For drawing a bitmap of colors on a 2D plane.
Lets say the user can place shapes down on the canvas. The shape is pretty simple - something like:
public record Shape {
public Color32 Color;
public IList<Vector2Int> Positions;
}```
I want the user to be able to place any arbitrary number of shapes down at once, and have them all be drawn. Simple enough - when the shape is placed, draw the color in all the positions, and when it's removed, remove that color.
The problem is - how to efficiently handle the cases when two or more shapes overlap? I think what I want is for the _latest drawn shape_ to always show on top of other shapes. To me it seems like I would need to store something like a sorted list of colors for each pixel, or maybe a "MaxHeap" style data structure. But it seems overkill to do this for each individual pixel. What's an efficient way to do this?
Hi. One question, if I have a list with like 1000 elements, each with a Vector3 StartPosition,Vector3 Direction and float TimeSinceSpawn, what would be the best way to render a line for each element in its corresponding position with its corresponding direction, knowing that the list is constantly changing size please?
sorry to be negative, but that is a beginner
i think im junior level
no longer @just installed vs level@
ye i get you, but you still got a lot to learn thats what i mean ^^
first no, second thats not how making friends works
of course!
so far im trying to figure out what im doing, this is a whole DIFFERENT WORLD (considering im coming from writing my own engine and godot)
just use unity 6 and hide the unity logo, people cant shittalk it then, as they cant tell its unity (and only people who have no clue are the people shittalking unity)
But i get what you mean, many label the Game as Slop Game if they see the Unity logo, without looking at the game first
But we should get back to code related stuff

What kind of lines are you looking for? And this is for playmode right?
With GL.Lines you can draw 1 pixel wide lines pretty cheaply
if you dont understand something and !learn isnt helpful, feel free to ask in #💻┃unity-talk about it
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Simple lines, like LineRenderer or something like that, or maybe a simple mesh. It is basically for a bullet spawner, but there might be thousands of bullets at the same time. And yeah, for playmode
I'll give it a look. Thanks
GL.Line will look similiar to Debug.DrawLine
Might not be what you want for bullets
If the lines have just 2 points, you could just stretch an object that has a mesh renderer
TrailRenderer is also a thing in case you want something like that
But having 1000s of objects each being individual might tank performance
You could draw the meshes with one of the instanced drawing methods
So it would be 1 draw call
my only question is... what is a "pixel per unit"
my pixel perfect camera has like that weird gap there
Think of Pixels Per Unit (PPU) as how many pixels fit into 1 unit of space in your game world.
If the PPU is lower, your game will look bigger, because fewer pixels are displayed out over the same space.
Did i explain that somewhat understandable
there you go
Also I tried your method and even when I crank the numbers up to the millions, the movement feels really slow and takes a long time to accelerate
https://scriptbin.xyz/alayinigul.cs
Use Scriptbin to share your code with others quickly and easily.
theres almost 400 lines here, im not sure what part you want me to look at. the only thing i notice is that u are still using AddForce rather than assigning the velocity
Hello so i'm having this weird "quantic bug" that happens if i start the project then launch the game, but disappear when i have the animator window opened in the editor... it's been a week kinda becoming desperate
has it hapenned to someone here ?
either way you're gonna have to debug and see what vectors you're assigning. plus the issue of using AddForce as i mentioned above. Tbh your code is very unreadable. I highly suggest getting away from having as much on 1 line as u can
You didn't describe the bug