#π»βcode-beginner
1 messages Β· Page 152 of 1
isn't there a texture = new Texture(renderTexture); to make a shallow copy?
That sounds plausible to me, yes
This is one area where I don't have much experience, alas.
Trying to sort a list but i think im doing it wrong somehow?
I played with RTs in a game jam once where I spent most of the jam creating a procedural level generator instead of making the game fun
whoops
iirc you need to copy it by using the GPU method built in
https://docs.unity3d.com/ScriptReference/Graphics.CopyTexture.html
random guess: you're using LINQ's OrderBy method, which doesn't do anything to the list
but if that hard read was wrong, context please!
Im about to copy and paste the code give me one second
But yes ur right
Using OrderBy
you didn't read the docs then did you
That produces a new IEnumerable<T>, as do all LINQ methods.
consult the docs for List<T>
you will find what you need
reading docs is overrated. /s
heretic
{
_current_index = 0;
PlayerPawns = FindObjectsByType<PlayerPawnBase>( sortMode: FindObjectsSortMode.None ).ToList();
PlayerPawns.OrderBy(pawns => pawns.BattlePawn_SO.SpeedOrder ).ToList();
for(int i = 0; i < PlayerPawns.Count; i++)
{
print($"{PlayerPawns[i].BattlePawn_SO.CharacterName}");
}
}```
you order the enumerable, create a list, and then...throw the list away
Oh really
yes really
I didnt realize
AddTwoNumbers(3, 5);
it's like you did this
the answer is 8. but you do nothing with the answer, nothing happens
line 7 sorts the list PlayerPawns, returns a sorted ienumerable, converts it into a list, then just throws it away without doing anything with it
So im not returning it correctly?
you seem confused
your not returning it at all
I am lmao
look at the methods you're calling instead of just hoping they do what you think they do
OrderBy takes an enumerable and produces a new enumerable.
I see
ToList takes an enumerable and returns a list containing the enumerable's elements.
Makes sense
now, you COULD write this:
PlayerPawns = PlayerPawns.OrderBy(...).ToList();
This would be a valid program, and it would do what you want it do (make PlayerPawns be a sorted list)
Yeah^^
however, this means that you're throwing out the old list and replacing it with a new one.
this does not sort the list referred to by PlayerPawns
it stores a new list into that variable.
on the other hand...
I see simple mistake on my part
You should not be using OrderBy...ToList at all here.
There's no point. Just call Sort.
and generates shit loads of garbage to boot
Which is ?
It's more awkward to use a custom comparison function.
oh wait, no it's not
very nice
i did this and for some reason the movement is laggy, velocity isnt clamped exactly to its max speed it just changes really fast from 20 something below maxspeed to 20 something above
Comparison<T> is a delegate type
you just need to write a method that compares two PlayerPawnBase objects
I get it now
rather than a method that turns a PlayerPawnBase into a comparable value.
don't you want to clamp the XZ velocity?
yea
then just clamp that and be done with it
your code is clamping the XZ and Y velocities whenever the total velocity gets too high
that's going to be very unusual looking
finished it:
but i get this:
NullReferenceException: Object reference not set to an instance of an object
Planet.OrbitPlanets () (at Assets/Scripts/SolarSystem.cs:109)
Planet.Update () (at Assets/Scripts/SolarSystem.cs:96)
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
solarS.sun is null
oh wait u pasted 2 classes..
Object reference not set is always b/c ur trying to access something thats null
smart
yupsomething is null on 109 of solarsystem script
who knows what because they pasted 2 scripts in 1 link
!code
π Large Code Blocks
Use 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 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.
whats wrong with this code?wehn i run it the movement is inverted so when i press w it goes left if i press s it goes forward or backwords
who is blud talkin too
perhaps your model/sprite/etc. is oriented wrongly
click on the object that NewBehaviourScript is attached to
how to change?
make sure your scene view is in local + pivot mode
The blue arrow you see is forwards.
you made it look like you were pointing out my code sharing method
e.g.
If the blue arrow doesn't point in the direction you think should be forward, then you need to adjust something.
no i was tryna do get the links to import code for myself
indeed, you're off by 90 degrees
yh
how do i change?
here's my suggestion
is it in blender i gotta change
parent this model prefab to a new empty object
Blender
Then you can just rotate the model however you need to.
You could also fix it in Blender, yes
i can just do it in blender and re export ittl be easier
Also, I see that you have a rigidbody on the model.
since you do, you should not be using transform.Translate
you should be moving the rigidbody itself
Even if you do, it's still a good idea to parent the model to an empty object. That makes it easy to adjust the exact position, to swap it out, etc.
what would the code look like?
doing it in Unity is faster though , and you need to separate ur mesh from main object anyway
https://docs.unity3d.com/ScriptReference/Rigidbody.MovePosition.html
Note that this works in world space, not local space
unlike transform.Translate
Just use transform.forward instead of Vector3.forward and it'll work out nicely
always keep mesh as child, this way rotations/scale is incosequential to main object with logic/colliders
transform.forward is the direction the transform is pointing in world-space
i have
and what do i do next
rotate the model so that it lines up with the parent object's forward direction
so, when you have the parent selected, its blue arrow should match where the model is facing
You've parented it to a cube. I said to parent it to an empty object.
oh
alright
So just delete the box collider, mesh renderer, and mesh filter from the cube
that'll give you an empty game object
you'll also need to move the movement component onto the root object
hello!
is there a way to have a function executed only for the first 25 frames?
yes
sure, add a condition that checks if Time.frameCount < 25. But what are you really trying to accomplish here?
^ ding ding ding
I am having an issue using a variable created on an object in editor.
Object1(EmptyObject) has moduleBuilder:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteAlways]
public class ModuleBuilder : MonoBehaviour
{
public static ModuleBuilder mb;
public List<Module> modulelist;
private void OnGUI()
{
if (mb == null)
{
mb = this;
} else if (mb != this)
{
Destroy(gameObject);
}
}
}
Object 2 is trying to access Object1's static property:
}
bool addme = true;
foreach (Module m in ModuleBuilder.mb.modulelist)
{
if(m.GetHashCode() == this.GetHashCode())
{
addme = false;
}
}
if (addme == true)
{
ModuleBuilder.mb.modulelist.Add(this);
print(ModuleBuilder.mb.modulelist.Count);
}
getting this error and a nullreferenceerror:
Objects are trying to be loaded during a domain backup. This is not allowed as it will lead to undefined behaviour!
What am I doing wrong logically here?
but yea, thers probably a better solution
in update?
What are you trying to make your game do here?
not "do something for the first 25 frames"
its till doing the incorrect movement
well, yes, you haven't moved the movement component yet
thats just an optimization (better way to do it)
yup, move the main parent.. the graphics will follow along b/c of them being child objects
you've managed to avoid screenshotting anything useful here
select the root object and show us the inspector
i want to save the renderTexture to a sprite thorugh a function, but i have 25 sprites and if i do a for loop in start function it makes all sprites the same bc the render camera doesnt update until the next frame
u can use a coroutine..
and wait until next frame
remove the rigidbody from the model.
yea but how do i stop?
you should stop after you've gotten to the last sprite
this sounds like a simple for loop to me
yup
foreach (var item in yourArray)
{
// Perform actions on the current item
// Wait for one frame
yield return null;
}```
private IEnumerator DoActionsWithDelay()
{```
if you want to have a rigidbody, then put it on the root object and control its velocity or position
ofc ud need to put it in a coroutine to use the yield return
now i gotta figure out why i shouldnt use transform.translate
oh
If you have interpolation enabled, setting the transform's position won't work.
The rigidbody will overwrite it.
MovePosition() tries to respect colliders as it moves, yes
// Move the Rigidbody using MovePosition
rb.MovePosition(rb.position + movement * moveSpeed * Time.deltaTime);```
you should only call (1) of those methods not two.. just add the vectors and stuff into a variable together
and only call the rb.MovePos. once..
The Rigidbody.MovePosition method is typically used within the FixedUpdate method for physics-related operations. However, Unity automatically interpolates the movement when you call MovePosition in Update, ensuring smooth motion.
i think you could use it from update..
interesting..
but yea generally bad. esp if ur setting its velocity directly.. like rb.velocity = thats def reserved for FixedUpdate
I haven't used MovePosition much so I was under the impression it was same as .vel or AddForce acceleration
its b/c it runs in fixedupdate anyway.. even if ur calling from update.. it probably takes the last one that was called b4 the fixedupdate kicks in
but im unsure exactly.. but i know that u can get away with it.. altho probably not very proper
yeah but so is addforce
yea.. thats another one you CAN use in update..
but i wouldnt anyway
yea but anyway.. he's right..
commonly keep ur rigidbody stuff in fixedupdate
what should i use then?
- get input from update
- act on that input in fixedupdate
I just know it from everyone preaching it like gospel lol
for my movement thats the best
what type of game are you making?
im new so i wannna just make something to practise but i would love to create mobile games in future
for simple movements I just usually go with CC

tbh CC is perfect for basic stuff..
it has built in stuff where it can walk up slopes and stairs..
and can handle basic verticallity like jumps and whatnot
Yeah, the only issue is going down the slops it skips but that can be fixed with getting slope normals (bit advanced topic)
is that the best for mobile games?
Rigidbody is more powerful and more natural
the genre/platform is inconsequential
CC is easier and better for beginners to pick up on
alr ill use that then thanks
you can use CC in update.. u wouldnt need to worry about splitting up ur inputs and movements
and that stands for character controller right
yessir.. you dont need a rigidbody if you go that route
isnt rigid body built in physics like gravity
look up Simple / Basic Character Controller for some tutorials
why wont i need it?
they're all about the same thing
going to tmr
b/c CC uses a capsule collider and a CharacterController component
gonna go work on my blender project
it does math internally to get smooth movements and stuff
character controllers can be reliably moved in Update and make it easy to move around and over colliders
^ as a beginner ur probably best to use the CC and work ur way up to a rigidbody
Physics consists of more than just gravity but yes. You'll get the entire behavior - many unwantedly unless you're making a physics simulator.
only thing with CC is you need to make your own Gravity but Unity has an example script
does CC have built in gravity like if im making a game twhere you skii would the gravity work?
without rigid body
also you can just use the new CC starter assets.
but learning the basics on how it works it probably benefit your learning
you will have to code in gravity yourself for the CC but thast basic..
you just can add a negative vector to ur variable b4 u use it in the CC move functions
idk what that is but will look into that
sounds intresting
The example from the docs illustrate moving, jumping and gravity: https://docs.unity3d.com/ScriptReference/CharacterController.Move.html
Jump animation wont play
https://paste.mod.gg/vivijqehsxey/0
The code ^^
A tool for sharing your source code with the world!
private void Update()
{
// Example: Move the Character Controller with gravity
float moveInput = Input.GetAxis("Horizontal");
Vector3 movement = new Vector3(moveInput, 0f, 0f);
movement.Normalize();
// Check if the character is grounded (you might have your own ground check logic)
bool isGrounded = characterController.isGrounded;
if (isGrounded)
{
// Reset velocity when grounded
velocity.y = 0f;
}
else
{
// Apply gravity when not grounded
velocity.y -= gravity * Time.deltaTime;
}
// Move the character using CharacterController.Move
characterController.Move((movement * moveSpeed + velocity) * Time.deltaTime);
}```
boilerplate example
has built in ground checking
the only cringe unity put there though, 2 movecalls instead of 1 even they themselves recommend calling it just 1 once lol
yes, that can cause problems with detecting grounding properly
literally they could've just put a + lol
doesent && grounded do that job?
oohh gross, lmao nice catch
isGrounded reflects the most recent movement. If you didn't move down at all, and you're on flat ground, you won't wind up with isGrounded being true
since you just moved horizontally over the ground without bumping into it
I don't know what you mean.
Is this the help channel?
read the top description
so many times I hit this button
I dont think they read those though xD
idk i used something like that in a 2d game tutorial i remember
π π
Exactly! xD
make it a Github thing
so many docs link to github (I think the new docs they did that) Netcode
Beginner coding help with Unity. Non coding stuff would go in #π»βunity-talk or an appropriate channel #πβfind-a-channel
well && just means AND in a conditional...
if (x > 0 && y > 0) or
{
if (y > 0)
{```
its just how the code is written, u could use a ground check with it and w/o it.. by using two if statements.. not really relevant to whether its a CC or RB but,
- a rigidbody doesn't have a built in ground check (you have to program it yourself)
- a cc does have one already
theres pro's and con's to each.. but CC is the fastest to get up and running a basic character for sure β
ill defo watch a couple vids and read about it but rn just gonna chill and work on my blender project
π good luck
ty
if you want a quick character that works out the box just use the Unity controllers
^ yup drag and drop bb
i dont want quick i rather it works better and take me more time than have roblox type movement
idk what roblox type movement is but this should work no?
ahhh beat me
you got both which is prob better π
well the quicker u get the bones set up the faster u can build / modify it to be a good system
roblox movement used raw axis and it dosent feel nice
is roblox fpv or third
or look
idk even know
any
i assure you with a few tweaks in inspector those character premade controllers feel pretty good
you just need to tweak them enough
stock sucks
yeah their gravity is a bit light for my taste
feels "floaty" (but then again its video games not realism xD)
yh i will test it
oh for sure.. thats a must for me.. first thing i do is go to my project and bump gravity up between -10 and -12
and drop my physics tick to be 60fps
I use -20ish lol
thats totally fine too π
Jupiter gravity
a bit realistic for me
all my projects prefix arcade- to the front lol
gives me an escape window..
yeah I've been making just "insert activity" sims
"well, its arcade, it isnt supposed to feel real"
so jumping is kinda not really priority
i made a joke a while ago about moving the ground downwards for a jump..
it actually works.. probably hella unperformant if i were to continue with it LoL
"Jump"
still trying to figure out how to make a proper elevator without twitchy bumps
u close the doors and shake the cabin.. then u just enable the new floor and open the doors
π
not yet, the pile of pallets are just baked into the big navmesh
i'll try em out undoubtfully tho
is there anyone else new here?
i lost my leaves a while ago.. why whatsup?
yeah they give them a decent "jump" feel
I'm new to many things today
thats a decent start
and i want to learn
check out !learn
:teacher: Unity Learn β
Over 750 hours of free live and on-demand learning content for all levels of experience!
damnit
they have good starter courses
courses like money?
ok
^ facts, follow along and dont be afraid to go out looking for more information
once your exposed to a new idea, if u dont quiet understand it completely look up extra resources on your own..
google and youtube are chocked full of unity resources
Unity answers was def my top goto from google
if you get hardstuck or softlocked on something just come here and ask for help
it still is today mostly, and the forums
i like stackoverflow myself
yeah though I find more c# stuff better there than unity
it does.. i bookmarked that VectorCookbook link i saw yesterday
always learning of new ones
Time to try and do this again! (for the 3rd times)
wait did Unity just do an inside joke ? or just coincidence lol
someone needs to make more interactive tutorials..
third times the charm they say
working on it
its very ovewhelming at first but eventually it will make sense
I was overwhelmed the first time I tried to learn
!bug
πͺ² To make bug reporting as quickly as possible, we made a bug reporting application for you. When running Unity choose Help->Report a Bug in the menu, or you can access it directly through the executable in the directory where Unity is installed. It will also launch automatically if you experience a crash.
π If your bug report is to do with Documentation, either an error, typo, or omission, you can report it by scrolling to the bottom of the page where you found the issue and click βReport a problem on this pageβ!
π‘If your report is to do with a new feature idea, you can check the Unity Product Roadmaps page to see if your idea has already been planned.
For more complete instructions on how to report bugs, access: https://unity3d.com/unity/qa/bug-reporting
this looks wrong what are you doing
also this is not code issue #π»βunity-talk
Is this a safe/valid way to display strings? it just makes me worry a little using {} like that
Debug.Log($"{playerName} was attacked by a wild {animalName}");
Guys does anyone know why the colors are so bland on my editor for visual studio? Like the "Vector3" is blank etc
maybe you have it set to the wrong language?
C#
!ide
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
β’ Visual Studio (Installed via Unity Hub)
β’ Visual Studio (Installed manually)
β’ VS Code
β’ JetBrains Rider
β’ Other/None
you have it configured for C# but not game development with unity
you could use instead Debug.Log(playerName + " was attacked by a wild " + animalName);
but nothing wrong with string interpolation, its even nicer when you have lots of variables to print out
cool deal, thanks
still having the faux hitbox issue - I found if I move the box it thinks it is colliding with back, the raycast extends a little bit farther. It's as if the hitbox for the wall is on the left room instead of the right room
Ah okay thanks
Preserving player's local y velocity correctly
(the raycasts extend from the center of the room to where out RaycastHit hit says it hit hit.point)
https://pastebin.com/wPAVLDst I got a script here that controls blendshapes, it works but is very annoying to constantly edit the strings of the blendshape name. Is there a way to get the component of the first second and then third blend shape? Kinda like m_Animator?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
so it's literally as if the walls on the rightare actually around the room on the left
i would start considering using a different scene.. and testing the thing a little by little..
maybe rebuilding ur pieces and trying..
idk, i watched in yesterday with this issue and im with Vertx, im stumped as to what could be happening..
at a certain point (when i have issues i can't solve) i try to start over or isolate the problem pieces to just theirselves.. to eleminate any possibility other things are messing it up..
try getting it working w/ the most basic of setups... and if that doesn't work then you can atleast rule out it being a bug in the project or something unexplainable..
but idk /shrug tbh
alright - what's most confusing is that when I click the pingable debug log it doesn't highlight the object the raycasat thinks its hitting
but it def is that object because if I mess with WallEZ's hitboxes it affects the drawn ray
I guess I'll just try and reconstruct it
see if I can replicate this bug
Do you happpen to be using hit.transform or hit.rigidbody by any chance
hit.transform.gameObject
and the scene has no rigidbodie
not a single one
hit.transform can give you a parent transform if it hits a collider under a rigidbody
^ thats screwed me up sooo many times
wait wym
if the function has arguments or retuens something that isn't void, you need a different type
well I have no rigidbodies so that shouldn't be an issue
I get what you mean nowthough
brain's just running a tad slow today
Show me your code (or link me to it again)
Sorry for asking again, may I have help with this please?
no it doesn't have arguments and it doesn't return anything, it just modifies variables in other gameobjects
okay, then that'll fit into a System.Action variable
he means sometimes ur raycast can hit an object down the hiearchy
but the raycast will return the root
"!code"
π Large Code Blocks
Use 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 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.
wait not me
if the collider is a child object
nah, I did want to see yours
yeah I realized a tad too late
see here
chunkers
yeah I've already more than confirmed the object being hit is WallEZ
and how should i create an array of action variables ?
because apparently it's a "delegate"
i wonder what that is
"delegate" is the type of a function
can someone help ne rq
ooh
it's not an array of variables or anything; you're just making an array of System.Action
System.Action[] x = new System.Action[3];
// Create an array of Actions
Action[] actions = { action1, action2, action3 };```
nvm
just called it "Actions"
https://pastebin.com/wPAVLDst I got a script here that controls blendshapes, it works but is very annoying to constantly edit the strings of the blendshape name. Is there a way to get the component of the first second and then third blend shape? Kinda like m_Animator?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Hey I am trying to make a random scrolling animation that selects a item (like what it looks like when choosing a mini game in Mario party) does anyone know how to make it or better yet a tutorial.
I am not really sure how to explain it well, I mean like in the order. So The first one is 0, second is 1, third is 2. I need it to access those rather than me typing a string and it finding it
reacreated the scene re-using my scripts and obv 3D assets - same issue and I don't really know what I should change unless I just go through the process of re-coding all of my room generation functions
maybe you can find something similar by searching Slot Machine ?
Just use 0, 1, 2, etc. in that case
thats kinda what i think of when i hear random scrolling selection
yeah but how do i do that in code.
I'm still unclear on what your problem is (and I don't think you've shown me the code?)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/* Script Purpose
* On Room Frame instantiation:
* add empty walls around them
* add actual walls adjacent to where walls already are (to prevent one sided walls)
*/
public class AddWalls : MonoBehaviour //Called when new room frame is placed
{
[SerializeField] GameObject blank, cam, parObj;
[SerializeField] BoxCollider linearOffset;
[SerializeField] private LayerMask wallMask;
/*
* blank: empty gameObject
* cam: the camera
* parObj: parent object of the frame, holds all of the walls etc. as children
* linearOffset: the box collider for the frame which determines its size
* wallMask: the mask for visual walls, used to determine if a wall already exists or not
*/
[SerializeField] float wallOffset;//percent of distance the wall is between the center of the frame and the edge of the frame
//I could have done it by distance but for some reason I couldn't figure out how???
//Called when new room frame is placed
void Start()
{
gameObject.GetComponent<Renderer>().enabled = false;
GenerateWalls(transform.gameObject);
FindNeighbors();
parObj.name = $"Room ({parObj.transform.position.x/6}, {parObj.transform.position.y/6}, {parObj.transform.position.z/6})";
}
void GenerateWalls(GameObject obj)//generates empty wall parents around a room on all sides except those adjacent to other rooms
{
for (var i = 0; i<= 3; i++) {
Quaternion rotApplied = Quaternion.Euler(0, 90f * i, 0);//adds 90 degrees each iteration
Quaternion rot = obj.transform.localRotation;//rotation of frame, applied to walls
Vector3 framePos = obj.transform.position;//position of frame
Vector3 offset = new(0,0,linearOffset.size.z * 0.5f);//offset from the center of the frame
offset = rotApplied * offset * wallOffset;
offset += framePos;
GameObject newObj = Instantiate(blank, offset, rotApplied * rot, obj.transform.parent);
newObj.name = $"{blank.name}{(NSEW)i}";//renames walls based on direc1tion they are facing
}
}
private void FindNeighbors()//finds if there are neighboring frames
{
float sizeX = linearOffset.size.x * 0.5f + 2f;
for (int i = 0; i<=3; i++)
{
//Debug.DrawRay(transform.position, Quaternion.AngleAxis(90f * i, Vector3.up) * Vector3.forward * sizeX, Color.red, 5f);
if (Physics.Raycast(transform.position, Quaternion.AngleAxis(90f * i, Vector3.up) * Vector3.forward * sizeX, out RaycastHit hit, sizeX, wallMask))//shoots ray, rotates by 90 degrees per iteration
{
Debug.Log($"{Quaternion.AngleAxis(90f * i, Vector3.up) * Vector3.forward * sizeX} {90 * i}");
Debug.Log($"Hit object {hit.collider}@{hit.transform.position} from {transform.position} with run index {i}", hit.transform.gameObject);
Debug.Log("Click", hit.transform.gameObject);
Debug.DrawLine(transform.position, hit.point, Color.red, 5f);
Debug.Break();
}
}
}
private enum NSEW//pos Z = north, pos X = East
{
North, East, South, West
}
}
!code
π Large Code Blocks
Use 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 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.
skinnedMeshRenderer.SetBlendShapeWeight(0, xposblendshapeWeight);
like this
thank youuuuuuuu
Hello Guys
I Have a noob problem i imported a project into unity and when i try to open code from the project it doesn't seem to know where to open it, it does open Visual Studio so i have the right editor chosen.
I don't know what "doesn't seem to know where to open it" means
i can only wish you luck mate @edgy fox as idk, but im gonna guess its ur system..
if u hand place the piece in front of a gameobject and then use a normal raycast method on that object. like put it on a gameobject and raycast forward with a mouse click or something) just to ensure my raycasts are working.. and debug what it says, etc
THANK you so much! You've helped me so much, you've helped me with avatars and this, may not be much but it's really good!
if a basic raycast works and detects that object the way it should. it'd be atleast a little knowledge you have
dumb shit: im instantiating a game object to clone it but for someeee reason when i clone it several times it goes like this:
cube (clone)
cube (clone) (clone)
and can you explain what's exactly wrong here?
yes, it sticks (clone) on the end of the original name
it sounds like you're cloning the clone
It doesnt know what path maybe? This is what i get when trying to open the code
the raycast is hitting an object that it should be missing
idk how i am tho im instantiating a game object
well that's exactly how you clone something, so it sounds relevant..
the red line is the raycast, it is "hitting" the white and orange wall
sounds like you aren't instantiating a prefab, yes
how do I convert an object with children into a prefab?
I can't see anything in this image. It's a small red line in what appears to be empty space
Do the walls not have backfaces?
Rotate the view so I can actually see what it's hitting
sorry my brain fell out my ears then but i got it now thankyou
so i have this script, basically it runs a fight seen. Is there a way to execute a method that does something, wait until the player selects one of three options, and then continues doing stuff?
make it a prefab,
drag in that prefab into the script instead of teh gameobject from teh scene
cool stuff π
how do you know that ray isn't from another hit? Are you getting exactly one hit in this image?
exactly one hit, Debug.Log says it is hitting WallEZ, the orange and white wall of which only one exists
basically it was a script error, where i was calling and instantiating the game object weirdly but i changed how i did it once i spotted it
if u can figure this out Fen you'll solve an issue he's been having for days i think lol
weeks actually, it's such a simple yet weird bug
and Collapse is off?
collapse?
it's an option in the console to hide identical messages
it could bemaking it hard to tell if your'e getting multiple hits
oh yeah it's off
although, you log i in there, so it would separate the messages out.
Show me the console after the code runs.
is blank an EZWall prefab?
Anyone know what as of late, VS Code doesn't want to auto complete unity stuff for me?
run through the !ide instructions
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
β’ Visual Studio (Installed via Unity Hub)
β’ Visual Studio (Installed manually)
β’ VS Code
β’ JetBrains Rider
β’ Other/None
should wake it up
Already have.
this is especially important if you were previously using the Visual Studio Code Editor package
are you using that package?
check in the package manager.
Nope. I uninstalled all packages/extensions and reinstalled them all, still not working.
blank is a blank GameObject with a hitbox. It does not have wallMask.
actually, you know, on second thought -- I don't get completions for message names...
okay, so EZWall exists in the scene from the start
and blank is a parent of the added walls
correct
is there any way to get the index of an array while you're doing a foreach loop ?
like the index it is in
check the size of the EZWall's collider while the game is running
If you need the index, I'd just do a regular for loop
i do wish we had Python's enumerate
1 room by 1 room size
its quite vague but right now i have a pitch black scene with no skybox and just use inside roomswith inside light, but i want to have lighting from the skybox of however you do it to get a lighting scene like this:
i don't get what you mean
but direct lighting just flashbangs my whole scene and goes through walls
for (int i = 0; i < array.Count; i++) { // ... };
do you have both sides of the mesh?
You need reflection probes.
Otherwise, every surface will reflect the skybox.
This is not a code problem.
I was wondering if the collider was getting stretched at some point.
Doesn't seem like it.
sanity check this by turning off the EZWall collider
but then how do i get the variable that's in the array ?
yeah that was a previous issue I had but adding a child 1x1x1 blank GameObject fixed scaling
surely you've indexed an array before
array[i];
this is no different from any other array!
this should make the raycast miss
WallEZ with no collider fixes the false positive issue but removes all true positives
it took me 25 minutes to make a account for unity again
and yeah it does miss
okay, so it is striking that collider, good
because the emails they where sending wherent going to the correct gmail
yeah I have reverified that over and over again but I get that - literally every sign is pointing to it being not that collider
the only thing I can think of is that the raycasts are shooting from the center of the wrong room - the room that the wall is a child of, and then being translated somehow back to the room being placed
because if I add 4 walls, it shoots 4 rays out as if the room being placed had 4 walls
(the white line means there is a wall there but transparent so you can actually see into the room)
that's because it's registering four hits
can i use raytracing instead of reflection probes?
that is useful information
I am unfamiliar with raytracing.
you generally don't use it for everything
yeah and if I move one of the wallEZs' colliders, the raycasts from newRoom (not a term in the code, will use that term from now on as newRoom and oldRoom need to be distinctly communicated) are longer/shorter depending on how I move them
oh, I see: that ray is shooting up and left
I was interpreting it as going down and right
it says i can't use < between an int and a non int, but it also says array.Count returns an int
ooh
Count is an extension method from LINQ that's used to count any enumerable
quick little diagram
what's linq ?
and there are no vertical components to the raycasts at all
System.LINQ provides extension methods to do various things with enumerables, like ordering and summing them
ah alright, I'm internally in my head using my own coord system
with which direction is up changing depending on my mood
but yeah I think you understand how it all is
(also, instead of raycasting, I would just remember which sides have walls assigned already)
so where is AddWalls in this situation?
wym?
is it attached to the room frame?
oh yeah
it is
with room being a blank GameObject with my custom coords in the title and frame having the scripts
and WallEZHolder being the blank GameObject that holds WallEZ
pro tip, dont use x,y,z use N,S,E,W,U,D then you can convert those to actual Unity cords when you instantaite Go's
Cardinal Directions are great when working on top down type stuff
yeah and for right now my game is essentially a glorified top down game
another thing is to keep ur eye on scaling.. if ur rooms/walls are child objects and they're all using primative colliders like a box collider or what not.. it could be that certain positions or rotations might wig out the actual fitment of those colliders
public float minY = 20f;
public float maxY = 120f;
public Vector2 mapLimit;
void ClampPosition() {
newPosition.x = Mathf.Clamp(newPosition.x, -mapLimit.x, mapLimit.x);
newPosition.z = Mathf.Clamp(newPosition.z, -mapLimit.y, mapLimit.y);
newPosition.y = Mathf.Clamp(newPosition.y, minY, maxY);
}```
trying to set camera limits, so it doesn't go off the map etc
problem: newPosition.x and newPosition.z works (WASD keys) , but not newPosition.y (scrollwheel), why is this?
i tend to try to use 3d modelled colliders with scales of 1:1:1 to keep everything as proper as possible.. just a little helpful tip
everything that is repeatedly cloned has a parent blank object with 1,1,1 scaling to maintain scale
just making sure, lol im just trying to cover all bases
yeah no worries lol
earlier I had a funny glitch where you could make WallEZ repeatedly bigger by clicking on a wall repeatedly which was fun
π not a bug, a feature
artist's recreation
ship it
my cursor is stuck as a vertical arrow in unity, does anyone know whats going on?
but in seriousness, just using a neighbor finder that finds rooms instead of walls and finding the NSEW of the walls will be helpful because then I just need to find the neighboring rooms (code already written) and see if for example the room is to the west if that room has an eastern wall
i havent saved in a while so id rather not close out of unity and reopen it
save and then close and reopen
well how do i save if my cursor is stuck like a vertical arrow
ctrl-s
ctrl
ah
ctrl s
or by just clicking File -> Save Scene anyway
Does this behavior continue if you add more rooms?
so, one 4-walled room, then several 0-walled rooms
do they all wind up getting four hits on the walls?
yeah all adjacent rooms do
So yours is also not doing this now? Wonderful.., Thanks Microsoft.
well, I don't think it's ever been completing those messages, specifically
didnt work, thats quite a bit of progress gone
it's completing everything that the static analyzer is actually aware of
thanks unity, for having a seizure
do you mean it was frozen?
because it doesn't matter if the cursor looks funny
that doesn't stop you from doing things
it must have been
and what if you add walls to the second room, then place a third room?
and if multiple rooms with walls are adjacent to the placed room itll still register
this setup for example triggered 12 times
4 for each of the 3 adjacent room
which really backs up my hypothesis the for loop runs for each of the adjacent rooms rather than for the room itself
I think you're instantiating something incorrectly.
so you placed 3 rooms and gave them 4 walls each
then you cleared your console and placed the room in the middle, and that caused 7 hits?
you should make sure you weren't just seeing old hits
see yall in another few months
I miscounted - 4 hits
unity didnt want to work so im gonna be back later
so it is still maxing out at 4 which makes sense as the for loop runs 4 times
I had 12 messages but each of the 4 times it happened I have 3 messages per hit
well, that is way more than there should be
ah, I see what you mean
3 log entries
Are all four hits from the same room's walls, or do they vary?
is there any difference between doing it either way?
the latter would require you to add [field : SerializeField] to each of the three properties so that they appear in the inspector
oh yea true, other than that?
I generally prefer the former. It's less annoying if you want to rename or change how DamageBonus works
If you decide it should be something other than just a getter for a field, then you have to take care to migrate the serialized data over
with [FormerlySerializedAs]
the property will have been serialized as something like field_damageBonus by Unity
i forget the exact name it uses
I'm going to be honest I can't tell
Click on the second log entry in each group. You used hit.transform.gameObject as the second argument to debug.Log
"Hit object ..."
that will highlight whatever you hit
did that, doesnt highlight
only in this specific case though
it's weird
Then the object doesn't exist anymore.
I wonder if your wall-attaching code is doing something bad here.
That's what I thought, but there is no code to destroy an object
Perhaps the new rooms are winding up with walls that are instantly destroyed
or that are otherwise moved or made irrelevant
no object with the proper layerMask to intercept the raycast is created or destroyed
the hit coords
What is the code to detect when the image moves???
I don't remember what code it was
is there a faster way to generate a random boolean rather that using a Random.Range ?
You'd have to code it.
Random.value < 0.5f is pretty simple
Random value > 0.5f
that might be slightly off because Random.value goes from 0 to 1 inclusively
(annoyingly)
They'll never notice 
I have this code here:
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
Debug.Log("Space Pressed");
movePlayer();
}
}
IEnumerator movePlayer()
{
selectedPosition = currentPosition;
Debug.Log("selected position:" + selectedPosition);
Debug.Log("current position:" + currentPosition);
yield return new WaitUntil(() => selectedPosition != currentPosition);
currentPosition = (SpacePosition)selectedPosition;
player.position = new Vector3(0.5f + ((((int)currentPosition) - 1) * 2), transform.position.y, transform.position.z);
}
For some reason, the second and third debug logs aren't running, indicating that the IEnumerator isn't running. The first debug log, however, does run, so it is registering that I pressed space.
Start Coroutine
What does it mean? Do I have to look up the code?
oh, i thought i could just run it like a method
There isn't a callback for an image being displaced. You'll probably have to poll the difference between the previous and current position to see if a move was made.
its not a normal method
it's a coroutine
fair enough
void Start()
{
// Call the Coroutine using StartCoroutine
StartCoroutine(YourCoroutine());
}
IEnumerator YourCoroutine()
{```
if you run a method that returns IEnumerator, it will execute everything up to the first yield
then it'll stop and return an IEnumerator
if you discard that return value, nothing more will happen
like when an unwanted kid shows their parents their trophies
it can work just like a normal method tho
π being a game developer ends up in some crazy search history
i feel im obligated to tell anyone that see's it.. "hey, im a game developer btw"
I could have commented the function better but to be fair that documentation is my most memorable comment I've ever written so
i started using [Tooltips] here lately instead of comments
i mean, it doubles as a comment when u read the script
tbf these variables were confusing to me at first.. and then i got the Min and Max flipped around
I have another question, is it possible to change the texture of a block with a script?
easier to assign a new material using the new texture
if you try to change the texture i believe you'll have to copy the material the block is using, change the texture on the copy and assign the copy to the material used
I mean, I want to detect the image when it moves and the texture changes automatically π
erm.. π€ interesting. care to elaborate a bit? still a bit confused what you mean by when it moves
like a sprite? like animation?
Sorry, I don't speak English very well, I speak French
I'm trying to do it when I press the image and move to whatever it is but I want the texture to change when it moves and when I stop moving the normal texture returns
I would like to know if there is any code to change the texture or something like that
It doesn't work for me with event triggers because it gets bugged and that's why I decided to use codes
they just told you how, swap the materials
event triggers only works if you put a 3D physics raycaster on the camera
otherwise its meant for UI / Canvas
all you need to do is check if its moving
if(thingIsMoving){//use one texture}else{//use another texture}
not sure if ur using a rigidbody to move the thing, but whatever ur doing theres a way to tell if its moving.. just use an if statement
https://hatebin.com/lqrcvmhqqe it would look similar to this
where you pass in w/e material u want to the ChangeMaterial() method..
if ur just moving the object with the mouse u can probably write ur own method that gets the last position and the new position in each frame
if they have changed its moving.. if not its not..
private Vector3 lastPosition;
void Start()
{
lastPosition = transform.position;
}
void Update()
{
// Get the current position
Vector3 currentPosition = transform.position;
// Check if the position has changed
if (currentPosition != lastPosition)
{
// Object is moving, change texture to movingMaterial
ChangeTexture(movingMaterial);
}
else
{
// Object is not moving, change texture to idleMaterial
ChangeTexture(idleMaterial);
}
// Update lastPosition for the next frame
lastPosition = currentPosition;
}```
it was caused by delayed destruction
sneaky one!
hey, do you guys know what this error is?
It means something on that line is null but you're trying to use it anyway
would it be a good idea to use a dictionary for an item equipment system? (equipped items on the player, stats, etc) if not how should I handle it?
how do I fix that?
is it a problem in unity or in my code?
Make it not be null
something is null at runtime, its not the code per se
is there a way to add a courotine to a delegate in the same way you would add a method?
hmmm, I tried to double click on the error and it seems that it is complaining on this line
isJumpSliding = timer.startTimer(jumpSlidingValue);
over here I am accessing a method in a c# script
so timer is null
how? I don't understand what null is?
did you read the link I've sent
yea
so it means the computer doesn't know which timer you want to run startTimer from, therefore nothing is there, hence Null
make timer not null
assign it
you mean like this?
That's declaring a variable
Assign an instance of that class to it
Timer timer = new Timer();
ohhhhh ok I see
The link is longer than one page, it's a whole damn resource that explains the concept from top to bottom
this is confusing to newcomers because this isn't how you assign MB instances
UnityEditor.EditorApplication:Internal_CallDelayFunctions ()```
what is this error? google tells me to reset all layouts, clicked that and doesn't work, what's going ?
error appeared when i created a new scene
you tried restart editor ?
I see that every time I start my editor. I should probably reset my layout..
ill try that thanks
That's why a C# course should be done first before Unity
worked, thanks
agree but this channel people want to make a game and forget you need basic c# knowledge
He was probably confused because of value / reference type differences
oh, so how do you do it?
structs and other value type fields get initialized with their default constructor so they're ready to be used
you are not allowed to directly construct a monobehaviour
default value for classes is null
the symbol is the same = for assigning anything
instead, you tell Unity to add a component to a game object. you can then store the reference it returns.
but the issue is Monobehavior scripts are instantiated when they are on the object
so unlike regular C# class you don't need to new() an instance and use either a serialized field or the GetComponent method
i don't understand what you mean by that
I meant when you attach a MB to a gameobject unity does its black magic to take care of the instancing
Unity just forbids a MonoBehaviour from existing without being attached to a game object
hence why you have to ask it to create components for you
yeah thats what I kinda meant, the instance is made by unity by being attached to gameobject
huh
digi was right
once you know how a delegate works, you wont know how you lived without it
helle yea!
so what I have to do is use GameObject.GetComponent to an object that I want to access the c# script, no?
Observer pattern I think is the technical term no?
you use GetComponent to get that Script so you can use it
d e l i c i o u s
or better to just Serialize the field in the inspector with public or [SerializeField] and assign by drag and drop @warm condor
If you have a reference to a game object that has the component you want, then you can use GetComponent<TheComponentType> to get it.
It is preferable to just get a reference to the component itself.
[SerializeField] MyComponentType target;
drag something into that Target field in the inspector
done
oh I see, and MyComonentType should be what? the game object or the script?
the script is the type
The script type. Don't reference things via GameObject unless you only want to perform GameObject functions
it seems that it doesn't recodnise the compnent type tho
[SerializeField] Script timer;
why did you write script, I guess you took "the script" too literal
do you have a type called Script?
i mean idk what to put there so I just wrote script
isnt your class called Timer
you declared it as such
you already have that part
all you need to add is the [SerializeField] so you can assign it in the inspector as said
Taking a C# course followed by !learn would be probably a better solution to all of this
:teacher: Unity Learn β
Over 750 hours of free live and on-demand learning content for all levels of experience!
yeah probably
best
this one does decent balance of both
Also another good resource
https://docs.unity3d.com/Manual/VariablesAndTheInspector.html
this is your current issue to learn
wait yall solved it?!
yea your right. I am ne wto c# and unity in general and I have been leanring it while making the game because I already have programing experience in college.
oh and btw I have fixed the problem so thanks for that
it required more context; adding a new room involved instantiating the neighboring room and destroying its existing walls
deactivating the walls before destroying them ensured they were gone in time
epic!, glad u got it worked out, i was starting to feel bad for the guy lol
did you program in C# though cause a lot of this is basic c# knowledge like assignment, the only difference here is the Unity API
I was a little surprised that it worked, though, since the offending logic ran in the Start method of the instantiated room
yup, it rings a bell.. ive had errors caused by Destroy() not being Immediate
the clue was that clicking on the logs didn't take you to a game object
even though the hit wall was included as context
bc it didnt exist! π€¦ββοΈ
(any longer (: )
no I was programming in python in school
ahhh yeah...wildly different than C#
C# will differ in one major way: it is statically typed
(Python has type hints, but those are optional)
I suppose you still have classes and all that like js but you need typescript for similiarity
I feel like they just hid an entire script from me that was also instantiating and deleting objects, and said they weren't destroying any of them
vscommunity can be set up to have type hints
helpful to me so i dnt have to peek definitions all the time
its on by default no ? I was trying to turn off but ended up just loving it
β‘
makes things a bit verbose to look at but you get used to it
thats why i suggested a blank scene with a hand placed wall..
i knew the raycast stuff didnt seem broken
The red herring was the belief that the raycast was hitting the existing wall
#π»βcode-beginner message
Like did they literally have a function called Kill Children?
which murders the children, yes
i think so yea
the plot twist was the instantiation of the existing room
important thing being it works now.. π
plot twist was that there was this entire other piece of code instantiating and destroying walls that was never mentioned
I've done that a few times, but generally only to make recursive prefabs that create the child copies before modifying themselves at all
ill have to remember the manage my destroyed objects better
so i dont run into a similar issue
well, it's only really going to come up if you're cloning existing objects and then trying to clean them up
true true, but when you destroy() an object it doesnt actually get destroyed until the end of that frame correct?
thats just something i need to watch out for (on my own projects)
iirc its marked for cleanup until GC comes in no?
Correct.
That's a different thing.
You're thinking of C# objects.
ahh ok
we're talking about UnityEngine.Objects
gotcha mb for butting in π
you good.. we're a community π
noob question but how do i drag the text (like there's a box around it so i can move it about)?
the unity lifecycle of objects is def something I should learn more π
you're in the game view right now
you can't move things around in the game view
switch to the scene view
also might want to toggle 2D
thanks π
click your text obj in hierarchy and press F
gotcha
in the scene view.. you can use the regular tool.. or this other one
cant think of its name
Rect Tool iirc
to many times in my earlier days "WHERE ARE MY ARROW GIZMOS"
oh wait Im in Rect tool mode
Itβs available when editing something with a RectTransform on it
I mostly use it to make it easier to see where the bounds of the selected object are. They can get lost in complicated UIs
u can actually use it for anything π
i use it to offset scale my objects sometimes
OP tricks
Oh yeah thats interesting you can resizing one side only
ah, the usual axes: M, C, P represented by magenta, cyan, and purple
Oh right. It works for some other components as well
lol, i wanted to try out pastels for a bit
how did you change that?
Itβll leave you handle-less when you select a light
You can change a frightening number of colors in the settings
in the big mass of editor colors stuff
in the Color preferences
Way too many colors
nah, u can go down a rabbit hole..
{
public GameObject leverUnswitched;
public GameObject leverSwitched;
public bool hasActivated = false;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerStay2D(Collider2D collision)
{
if (Input.GetKeyDown(KeyCode.E) && hasActivated == false)
{
Debug.Log("working");
hasActivated = true;
leverSwitched.transform.position = new Vector3(0, 0, 1);
leverUnswitched.transform.position = new Vector3(0, 0, -5);
}
}
}``` why is this not modifying my transform.position for both variables
the debug.log is being called
Do you have any errors
nope
Do the objects you're trying to move have CharacterControllers
no i thought if they had transform it wouldnt matter
a CharacterController would interfere
What are those two variables set to
2 tilemaps
Are they objects in the scene or prefabs
ive got it working now
however its really janky
like sometimes i press e and it does nothing
and then just magically works one time
Because you're checking input in fixed update (onTriggerStay runs in FixedUpdate)
i thought it ran every frame your in the collider
no fixedupdate (default settings) runs 50 fps
It runs every physics step you are in the collider
it says every frame
While input checks on frames
means the method is ran only once for each physics frame that runs im sure
as opposed to multiple times per
huh why doesnt visual studio say that
put a debug in the update and one in the fixed update.. you'll see how differently they are
yo can you have rigidbody2D velocity instantly accelerate instead of slowly
they probably could phrase it differently.. but im assuming its common knowledge so they dont go into deep details
you can use an Impulse force mode to have the entire force happen at once
could also just set the velocity manually..
I have a problem with my vehicle's steering wheel, i can get it to rotate back to its original position after turning for some reason
!code
π Large Code Blocks
Use 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 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.
theres no code to turn it back..
i thought i was already doing that?
if ur not pressing a left or right nothing happens
how would it rotate back when theres no code to run?
Yea ik but what should i do ive tried a lot
Make a logic to turn it back
Ah mb
u can add teh rotation after the if statement... and just change it back in the else statement
I feel like theres a better way to do this (this doesnt even work) I'm just trying to see if the object I clicked has stats
well either the raycast didn't hit anything, or the thing it hit doesn't have a Stats componenet
So i just rotate back using rotation function in the else statement ok imma look at that
something like that
set the rotation to be facing forward or w/e then outside the if u can just use whatever rotation you use
I use the GetAxis Horizontal thing, so i just need to set it to rotation(0,0,0) right?
// Get horizontal input
float horizontalInput = Input.GetAxis("Horizontal");
if (Mathf.Abs(horizontalInput) > 0.1f)
{
// Set the rotation based on input
RotateSteeringWheel(horizontalInput);
}
else
{
// No horizontal input, set the rotation back to zero
SetRotationToZero();
}```
could do this..
i was thinking more like this tho ```cs
void Update()
{
float horizontalInput = Input.GetAxis("Horizontal");
if (Mathf.Abs(horizontalInput) > 0.1f)
{
desiredRotation = CalculateRotation(horizontalInput);
}
else
{
desiredRotation = 0f;
}
RotateSteeringWheel(desiredRotation);
}
so the steering wheel always rotating after the if/else statement.. but its the if/else statement that would set w/e rotation u want
Im getting confused
this will always run
Ohh gotcha
the if statement just sets what desiredRotation would be
would a virtual camera with cinemachine mess with it?
Yayaya i understand
a cinemachine virtual camera is like a placeholder.. the camera just gets positioned to where the virtual camera is..
still functions exactly like the main unity camera (b/c thats what it is)
you say hit.collider.GetComponent
just remember that its trying to grab the component from the object with teh collider..
(that may not necessarily be the main root gameobject, for example if ur collider is on a child object of it)
but if theres no Stats.cs or w/e it'll be null.. if there is one it'll find it..
if(hit.collider.TryGetComponent(out MyScript myScriptReference))
{
myScriptReference.DoFunction();
}``` ```cs
MyScript myScriptReference = hit.collider.GetComponent<MyScript>();
if (myScriptReference != null)
{
myScriptReference.DoFunction();
}```
both of these do the same thing
you can Debug.Log(yourReference); to make sure its getting assigned (or not)
where to begin learning?
!learn
:teacher: Unity Learn β
Over 750 hours of free live and on-demand learning content for all levels of experience!
how many children would Room (0, 1, 0) have? Would it be 5 or would the children of the children such as WallEZholder(clone) be considered children as well?
like if I do transform.GetChild(2) would I get roof or BlankEast
ah its the former
Instantiate(wall, hit.transform.position, Quaternion.Euler(new Vector3(0, hit.transform.eulerAngles.y + 180, 0)), transform.Find($"Blank{(NSEW)i}"));
why does this code not make the wall a child of Blank{cardinalDirection} - if I debug log it transform.Find($"Blank{(NSEW)i}")); returns null
yeah debug logged it to find out which one it was
nvm I'm dumb, the transform is the fram's transform
not Room's transform
Rubber π¦
still doesn't work
Debug Log still returns the child obj though
but now it just doesn't instantiate anything
Store the result of instantiate in a variable. If you pass that object to the second parameter of debug.log it'll highlight that object in the hierarchy when you click the log
See if that object is where you expect it to be
Then it's probably destroyed between the time you spawn it and click on the log
yeah
oh I know what the issue is
all children are killed and remade fresh when a new room is made
and this runs the same frame they're destroyed before new ones are made
is there a way to cache a command to execute next frame
im not sure set it to an instance of an object
how did you assign TimesClicked
TimesClicked is null