#Gameobject.add in a while loop not working the same as a debug statement
1 messages · Page 1 of 1 (latest)
the second line works as intended but the first one inputs the first object the raycast hits in every place after 2
this is in a while statement and name tic is inceased every fame up to 4
also note that they are right next to each other
show your !code
📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
not just one line
The entire script.
Is there a Rigidbody2D on a parent of these objects?
no
I believe RaycastHit2D.transform gives you the transform of the parent rigidbody2D, if one exists
instead of logging transform.tag, just log transform
that will be more useful
that doesnt fix it though
of course not, but it'll change what you're logging
do you see a different Transform being logged every time?
or are you seeing the same Transform many times?
I have all of the objects named the same thing so i need to edit the code to allow me to differentiate the names
give me a sec
alternatively
Debug.Log("Hit: ", trueRaycastHit2D[nameTic].transform);
Debug.Log can take two arguments
The second argument is the "context". It can be any unity object
Clicking on the log entry will take you to the object in the hierarchy.
ok thanks
I had this exact issue before I found out about the second argument
was trying to find one object out of thousands I instantiated
show me your code.
i have no idea where it is getting void from
ah, so you tried to pass the result of Debug.Log into the second argument
and it returns void
Do you have many colliders on the same transform?
nvm again the debug log is working as intended
i looked at the wrong part of the log sorry
all of the object that are bieng detected are identical
are you still there?
i fixed it