#💻┃code-beginner
1 messages · Page 485 of 1
do the bomb and coin have parents maybe? and the baloon doesnt?
no bomb and coin are just prefabs
if i remove the spin script it works fine though but they are not spinning on their own axis they just move left
if you remove the move script does it work then?
yup if spin script is removed they are left perfectly
no
i mean if you remove the move script
not the spin script
nope then they willspawn still
huh
yup they are rotating
the way you want it?
i removed moving script and they are rotating on their own axis<
i want them to rotate on their own axis while moving left
yup the way i want it but they r not moving
try adding a , Space.Self at the end of the Rotate
as a 2nd parameter
you shouldnt be using Find ever, and also gameOver should probably just be stored in a GameManager or something
it is a tutorial prototype so it is a premade, where i have to solve the bugs
space parameter didn't worked but now i think the problem is in moving script i will try to debug it 🙂
didnt work as in error? or as in the problem wasnt fixed
what if you try doing transform. instead of Vector3.
transform dont have a left
you need to do -transform.right
ok let me try
this happened
is there something like pivot type maybe i have changed it
i got to know the issue maybe, the z value is also changing but i didn't told it to do so
you are telling it
Vector3.up * ...
Vector3.left * ...
you can just do new Vector2(-1, 0) if you want
should i use up
for left, or 0, 1 for up
still same
does anybody know a good tutorial that i can follow for lighting
The one that i am following all constantly have different button layouts which makes it super hard to follow
maybe dont follow one thats 2020 when your on 2023 🤔
and also its different because its setup much easier in the newer ones im pretty sure
Hi everyone! I need help: I make a game with ennemies helthbar, all work. But when I add more game featurs, ennemies healthbars strangly stop working! skript seems good and no console errors, can someone help me?
what features?
It's External things that no have link with the healthbar
idk how you want me to help if you dont wanna tell me what you did
Ok I will send some screenshots
again, you should look at #854851968446365696 to see what you should include when asking for help
https://paste.ofcode.org/Gq7hWGLeVZNsRAjyffeuUL So this is my ennemy script
https://paste.ofcode.org/n3fHFS22ydYCDXRu73QgAg The healthbar code
I am sorry @slender nymph It's a little difficult to resume my problem in a paragraph
if you cannot describe your issue, then how do you expect anyone to be able to help?
I don't know how to make it my game is already very advanced
Your first paste does not work
There's no need for your methods to call instance when they are part of a singleton.
And as was mentioned; this code does not explain anything. Nothing in here could suddenly stop working.
Yes I don't finish I have other things to send of course
https://paste.ofcode.org/Fh4eSSJdwsC4XmhxzHSYS4 try this for the first
I have still not gotten your explanation as to what stops working. You're very vague
How does it stop working?
teslaHealth = GameObject.FindGameObjectWithTag("Tesla").GetComponent<TeslaHealth>();
gameManager = GameObject.FindGameObjectWithTag("GameController").GetComponent<TGameManager>();
This is unnecessary by the way. You know how to make singletons, so you should to it here too unless there are multiple instances for some reason. You should never use Find methods.
Other than that the code looks fine, unless you explain what breaks
so i can remove this part of code?
You should consider replacing the Find methods I pointed out in favour of singletons if there is a single instance
But, this is not part of your initial problem so feel free to ignore it
A little short video record of my problem will be helpfull? With other objects content?
So if my attack not able to one shot an ennemy, it will become invincible and health bar stop working
is the problem not you just using a static instance and changing the health of it? meaning its only 1
but you need seperate for each skeleton?
huh
thats the complete opposite of what you want
so ctrl + z ?
what you need to do is not use a static instance
yes i not used
The strange thing is why worked before and not now
Somone wants to send him my game to take a look in private?
i already told you what to do, which you say you arent doing that which your code said otherwise
your code links dont work !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.
when you only had one object that needed a healthbar, your singleton worked just fine because it is literally designed to only have one single instance at any given time. you need to not be using the singleton pattern for this. and do not abuse static just for easy referencing.
so how can i replace singletons?
you just delete it
you dont replace it with anything
delete every instance?
what?
you delete the singleton
its a variable
its not that difficult if your paying attention
ok health works but the healthbar is still full
now the last problem is the healthbar
You will never believe me
It's actually worked! I'm so thanksfull, you saved my game!
what is the difference between Input.GetAxis and Input.GetAxisRaw, i don't understand what the unity API said
wdym by smoothing
https://docs.unity3d.com/ScriptReference/Input.GetAxisRaw.html
Returns the value of the virtual axis identified by axisName with no smoothing filtering applied.
no smoothing is applied for Input.GetAxisRaw, this means that for digital input the values can only be -1,0,1. there is no "gradually move toward the value"
Use Debug.Log to print the output and you'll see what I mean
thanks
another problem:
every 5-10 times i playtest, it tells me this error
UnityEngine.Transform:set_position (UnityEngine.Vector3)
Cam:Update () (at Assets/Scripts/Cam.cs:46)```
this is the code for the script
public GameObject cam;
public GameObject player1;
private Rigidbody2D rb;
public static float y_offset = 0;
public static bool is_retracting = false;
void Start()
{
rb = player1.GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
if (is_retracting)
{
y_offset -= Mathf.Pow(1- 1/y_offset, 5);
if (y_offset <= 2.5f)
{
if (y_offset <= 0.85f)
{
is_retracting = false;
y_offset = 0;
}
y_offset /= 1.001f;
}
}
if (rb.velocity.y < -30)
{
y_offset += Time.deltaTime / 2;
}
cam.transform.position = player1.transform.position + new Vector3(0, Mathf.Pow(y_offset, 4), -1); // this line is making the error
}
even if is_retracting is false and velocity is higher than -30
it still happens
Aren't you dividing by zero
On the third line of Update
If y_offset is zero
y_offset -= Mathf.Pow(1- 1/y_offset, 5); ?
i just realized that
but it works fine when i do the smoothing
aka the part in the is_retracting
but thanks
i changed it to this
public static float y_offset = -0.01f;
sadly i can't replicate it on command, but i will say it here if it still has a issue
it isn't infinity now
but it's 3.386269e+27
which is basically infinity
but no errors
it was because it got teleported 3.38 octillion units upwards
idk why
wouldn't this be septillion not octillion ?
just looked it up, nope octillion
septillion is 1e+24
are you in europe?
no
oh ok . Thought 3.386269×10²⁷ was septillion . alr 😛
idk why, but in third grade i wrote down all the numbers multiplying by 10 each time with their scientific notation and name
so i have it all written
i did it until 1 googol (1e+100)
ohh googol wait..gooogle 🤯
When you divide a number by a really small number, you get a really big number.
When you then proceed to raise that really big number to the 5th power, you get an even bigger number
hence your huge value
And since it's actually a huge negative number raised to the 5th power, it remains negative. So when you do -= with it, you end up with a huge positive number.
but why is it so random
only happens every like 30 mins of playtesting
Because it probably depends if:
if (rb.velocity.y < -30)
{
y_offset += Time.deltaTime / 2;
}``` happens before `is_retracting` becomes true
it is meant to be like that
Also some of this code is really nonsensical
wdym
nvm i misread something
lemme show a vid to show why it's meant to be like that
here, the camera not following up with the player is the if statement that you sent, then, when it touches the ground and it's previous velocity was -30 or less (meaning it landed after the the camera/player misalignment happened) (the detection happens in another script btw), it makes is_retracting true, making the smoothing effect when it lands
when i instantiate something as a child of an object it spawns at the bottom of all the children how do i make it so it spawns just under the parent
cheers
I'm creating a whole bunch of gameobjects at runtime, any way to keep them so I can save them in my scene?
just need to do it once
Drag them all into the assets folder to make prefabs of them, then drag them all back in when you're done, unpack them from the prefabs, then delete the prefabs
how do you check if something is active because .active, .activeInHeirachy and .activeSelf isnt working
in what way are any of those not working
in what way is "not working"
Anyone by chance know the update method for odin editor windows is called? Wanna filter a list based on a checkbox (bool) live in the editor
I know technically wrong discord but the question is so simple I was hoping I didnt need to join another discord for it
the bool was the wrong way round nevermind
I have a singleton class with a public instance, but I want calls to instance.StopAllCoroutines() to be private. How might I accomplish this?
Make a private function that calls StopAllCoroutines
you cannot change the default access modifier of StopAllCoroutiines neither can you override it as it is neither abstract nor virtual
can you collide Ui into eachother
because im trying to get a button to be stopped by an edge collider and its not working
the button does have a rigid body
why? what are you trying to achieve
a button that slides down and then gets stopped by a collider
why does it need to be stopped by a collider
so it doesnt slide off the screen
so just animate/tween it?
why does it need physics
cause its a physicy game
its a button
screen space objects should not have physics
you can just get the same result by tweening it i dont really understand
Any recommended workarounds? I don't have any calls to it, but I have some logic that will get messed up if I forget and add the call down the road
did you not understand what I wrote? There are none
Yes. I was curious if you had a "this is what I would do in your instance" or "best practices are to X"
if you really must prevent outside calls to StopCoroutine then you can just hide the method with your own method that does something like log an error. something like this:
public void new StopAllCoroutines() => Debug.LogError("StopAllCoroutines may not be called on this object");
of course in order to call StopAllCoroutines from within this class you must then cast it to MonoBehaviour and call it on that
there really should be no reason to need to do this though
cause i need buttons that are stacked up high and then when I click them the ones above it fall down and hit the collider and so on
thanks
Because I just should be intentional and not call it?
correct. much like you wouldn't just go passing everything to Object.Destroy all willy-nilly, you shouldn't just go and call random methods for no good reason
not particulary sure why my bullet starts spazzing out when the player moves, im applying force to the bullet when i instantiate it
*shoots fine normally
im either stupid or i dont see anything wrong with the bullets?
ahh i see your mouse is right for example but bullet goes somewhere left?
is that what you mean
yeah
should say that instead of spazzing out then lol
my bad 😄
you aren't using the direction to the mouse for this, you are just using the mouse's world position as the direction which makes very little sense
okay so i should calculate the direction from the player to mouse cursor im assuming
yes
alright thanks
public void LateUpdate()
{
int newStateHash = Animator.StringToHash(state);
AnimationClip clip = GetAnimationClipFromHash(newStateHash);
print("Normalized time: " + time / clip.length);
print("Current state: " + state);
anim.Play(newStateHash, 0, time / clip.length);
print(clip.name);
}
anyone know why this wouldnt be working? im trying to make an editor s cript.
the prints are going through, but the animator isnt playing.
this has the executeineditmode attribute, so
idk what the problem wis here
fixed it
Hiya, im trying to increment a value overtime based on time in order to check for cooldowns after things are paused, how should i implement increasing it when its paused?
ive tried many things but nothing seems to work, this was my latest attempt but :p
why arent you doing pausing with Time.timeScale = 0f? or is this just to pause one thing, not the entire game?
This will add 1 to lostTime every frame that Pause is true after the first second of gameplay
That doesn't really make sense
If you want to keep track of how much time has passed this frame, that's what Time.deltaTime is
i see
Time.time already stores the time elapsed from the start of the game
Not sure whether you'll really need to do that, but storing Time.time before and after the pause gives you its length, when the values are subtracted
If this is running each frame you would want to use Time.unscaledDeltaTime here
Not Time.time
And no need for any clamping
Hey, i have a 5x5, 10x10 and/or 15x15 (only one is rendered at a time) grid. i'm making it fit the screen (width-wise). if i fit the 5x5 grid to the screen then 10x10 and 15x15 grids are rendered outside the camera view (which is always static), which out of those options is better for retaining quality?:
change camera orthographic size to make grids fit the screen?
or change the size of tiles in the grids to make it fit the screen?
(a tile is a 1x1 unity's units square sprite)
this is running in an [ExecuteInEditMode] script. why wont it let me update the hitBox and hurtBox fields? the hitbox and hurtbox fields reference a scriptable object list.
Because your code is setting those fields
hitBox = moves[newStateHash].hitBox[frame];
oh right. so how am i meant to recieve these values? the idea is that i want to reference the list and update its values from this script.
Not sure what you mean by "receiving" the values. You're trying to change the list here?
This code wouldn't change the list, this code changes the hitBox variable in this script
It's definitely better to change the size of the camera. Think about it this way, if you make the user able to zoom in and out, will you change the size of the tiles and manually align them according to the input or simply increase and decrease the camera's size?
im trying to access an item in the hitbox list with the frame index to modify the bounds values
To change that value you would need to do something like
moves[newStateHash].hitBox[frame] = someNewData;```
Your = sign is backwards
how would i access the original valuye from the list, though?
With the index
Like this
was thinking the same, just wanted to hear other's opinions, changing tiles' sizes could get out of control or difficult to manage
The problem is you're doing it every frame right now
yeah i just realised that. how am i meant to only do it once?
And also you're never changing the list data itself
I would really recommend using a custom editor for this instead of whatever this setup is
i've written a custom editor window
thats what enables the slider and pop up window
i think i know what i ned to do now
sorted it out
why isnt ondrawgizmo running? its not even running print.
Are gizmos enabled in your editor?
!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.
i have this code in update to spawn stuff every 5 seconds if the game is running which it is, in my game manager script i set the bool to true at the start and it shows it in unity, why is this not working
if(Time.time>i && gameManager.gameisrunning==true)
{
i += 5;
Instantiate(enemyPrefabs[Random.Range(0,2)], randomspawnpositionenemy, Quaternion.identity);
}
if(Time.time>o && gameManager.gameisrunning == true)
{
o += 5;
Instantiate(powerUp, randomspawnpositionpowerup, Quaternion.identity);
}
its not spawning in
- !code
- What function is this in
📃 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.
update
it was working before i added the bool but id like to have the bool so it only spawns when im alive and not when ive died
Add this log:
Debug.Log($"Time: {Time.time}, i: {i}, o:{o}, gameManager.gameisrunning: {gameManager.gameisrunning}");
https://gdl.space/quloteniye.bash this is for it to stop spawning after death but it doesnt even spawn in the first place
bruh how do i use this
use what
the gdl space
paste the code, copy the link, post it here
like this, but generally with actual context
oh
do i put that in both if statements
put it outside any if statements
If you put it outside of any if statements and nothing logged, then this script doesn't exist
This would have been good to point out from the beginning
you're going to need to fix that
code stops entirely when it encounters an error
Something on that line is null but you're trying to do something with it anyway
double clicked it and its something with this line of code https://gdl.space/deliwufuce.css
did i do it right? dont think it worked again with the link lol
in unity i have an empy called gamemanager and attached the gamemanager script, i then just have a bool which is called isgamerunning and i put it to true at the start. then on my spawn manager i get its component and use that code
Where do you assign a value to the variable gameManager
sorry im a bit slow today, wdym. a value to the bool or? can you give me an example
Where are you assigning a value to the variable named gameManager
In the script that you're getting the error in
somwhere there must be code that says gameManager = something
else it is not assigned
ohhh here
Or in the editor
let me guess
That's where you create the variable
it has to be public
where do you assign a value to it
more than that you need to assign it
Where do you tell the code which GameManager this variable holds
Okay, and does the object with this script on it also have a GameManager?
no my gamemanager script is only on the empty
Then that code won't do anything
i thought i only had to call it
So, when you assign gameManager to "The GameManager component on this object", it's assigning gameManager to nothing.
since there isn't one on this object
you need to somehow tell the script which instance of GameManager that variable should refer to. You haven't done that properly, so it doesn't know, and you get an error when you try to use it
ohhhh i gotcha. thanks guys
yea it works now, thx
sorry for being a pain in the ass lol
I have a problem in my pixelart game, I am using a small resolution and I'm not sure on how to stop my charater from moving between pixels, you can clearly see it between 2 pixels and not snapped in the pixel grid
Are you using a pixel perfect camera?
https://docs.unity3d.com/Packages/com.unity.2d.pixel-perfect@1.0/manual/index.html
ok thanks, seems to work
rb2d velocity is logged as being active hundreds of times a second, not exactly sure what to do for fixes though this is probably a super ineffective way to code this anyway
{
touchingGround = false;
Debug.Log("In air");
}
if (touchingGround && Input.GetKeyDown(KeyCode.Space))
{
rb2d.AddForce(new Vector2(0, jumpHeight), ForceMode2D.Impulse);
}```
? rigidbody velocities are active all the time am i missing something?
elaborate a bit
i assumed velocity.y would only be active while im actually moving on the y axis
im only moving back and forth here
im not the most informed
i can just change it into something more effective got any ideas
what are you going for?
you wouldnt need to check to see if you are in the air if you have a ground check
i modified the code a little to add collision checks
{
rb2d.AddForce(new Vector2(0, jumpHeight) * Time.deltaTime, ForceMode2D.Impulse);
}
}
private void OnCollisionEnter2D(Collision2D col)
{
// allow jumping again
touchingGround = true;
Debug.Log("touching");
}
private void OnCollisionExit2D(Collision2D col)
{
touchingGround = false;
Debug.Log("Not touching");
}
}```
debug.log says im touching the ground and should be able to jump but nothing happens
im probably using an outdated jump thing
There is no outdated jump "thing"
is rb2d.AddForce(new Vector2(0, jumpHeight) * Time.deltaTime, ForceMode2D.Impulse); up to date? i saw a few conflicting things about it
i just clarified
And I'm clarifying
i saw a few posts talking about some things being out of date regarding that line
is it fine?
Link said posts?
lost to the sands of my search history
also i have tried it and its not working which is why im asking
i'd probably use OverlapCircle for ground checks on a 2d projet
How do you know it's not working? You have no way of verifying it's even running in your code. You're assuming it is.
or just a raycast
public class PlayerMovement : MonoBehaviour
{
public Rigidbody2D rb2d;
public LayerMask groundLayer;
public float jumpHeight = 5f;
public Transform groundCheck;
public float groundCheckRadius = 0.2f;
private bool touchingGround;
void Update()
{
touchingGround = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, groundLayer);
if (touchingGround && Input.GetKeyDown(KeyCode.Space))
rb2d.AddForce(new Vector2(0, jumpHeight), ForceMode2D.Impulse);
if (!touchingGround)
{
Debug.Log("In air");
}
}
}```
i use raycast arrays for 3D.. but for 2D i typically use something simpler since its not really something (for me anyway) that needs to be super accurate
usually circle does the trick for 2D
hold on gotta look up overlapcircle
raycast arrays is kinda nuts
deltaTime doesn't belong in AddForce
should return a boolean.. (either true or false)
at that point just use a boxcast 😅
then u can do ur thing for whatever u are
something like this kayla
u just use a position near the feet
and u can use a layermask soo it only detects the floor
(not the player itself)
you dont add Time.Deltatime on anything physics related since it already has it incorporated in it
would that work if i like ran up against a wall
seeing as it seems to only affect the bottom
I like it. its probably my most used ground/check method
i haven't really started using alternatives yet.. but i shall soon enough
been wanting to give the overlapsphere a try
the ground check is usually for ur own logic (applying jumping, sliding, etc)
the rigidbody should take care of collisions w/ walls all on its own
hgmhhmhmg this isnt working for me i cant wrap my little noodle around it
its fine i dotn want the mods crawling around on me because i havent made a thread yet
well if ur actively working on a problem and people are responding you'll be fine..
theres no other conversations going on right now that it would flood or anything
not what happened last time but probably
i dont get the layer thing i dont really mess around with layers alot
ive put the player on its own sorting layer and set the layer in the inspector to default
You're made to make a thread because of your general belief of "just tell me" attitude which isn't allowed here. And as I told you, if you insist on doing so, use a thread.
You've spent hours on a single question. This channel isn't your 1:1 tutoring classroom.
But go ahead and say what you will.
ive spent hours developing on a question into other things but i didnt come here to argue 
But again, if you find yourself on something for a while, use a thread.
Just to whine apparently, I'm only responding to this. Carry on with your questions.
oooh.. ya see i was unaware its been hours lol.. yea best make a thread if ur on the same issue
you see. ive made myself out to be the calm and collected sleek model train. while you my friend are the frustrated seething coal based train. heh. guess i win this little internet argument.
it hasnt been hours-
hold on im gonna read up on layer collision
if u use a layermask.. select the layers u want the groundcheck to detect/interact with..
the reason behind it is to
- check less things
- soo ur not checking the players collider (as ground)
good to hear
are there any setups for github actions besides game-ci ?
i went to set it up, and found five major bugs in my first two hours. i definitely need a project like that, but, i guess i'm not comfortable with a project with onboarding bugs
I am following this youtube series
https://www.youtube.com/watch?v=gPPGnpV1Y1c&list=PLGUw8UNswJEOv8c5ZcoHarbON6mIEUFBC&index=4
and ran into a problem at the second video 15:42
The second video in the Lets Make a First Person Game series!
🖐In this video we are going to setup the foundations for our interaction system.
Come Join us on the Discord!
🎮 https://discord.gg/xgKpxhEyzZ
💚 Thanks for watching!
Helpful Links
https://dotnettutorials.net/lesson/template-method-design-pattern/
You may want to consider telling people what the actual problem is.
Assets\Scripts\PlayerInterract.cs(41,34): error CS1061: 'InputManager' does not contain a definition for 'OnFoot' and no accessible extension method 'OnFoot' accepting a first argument of type 'InputManager' could be found (are you missing a using directive or an assembly reference?)
Reminder that things are case sensitive
Also, don't confuse the Player Manager with Input Manager (a script) - I'm assuming that's why you felt the need to show the new Input Manager images.
I'm running into issues with picking up items in my first person game, whenever I go to pick up an item the anchor position seems to be the thing moving? but im setting the book as its child, and moving it to the anchor.transform.position, what am I missing here? https://i.imgur.com/ljAmdyt.gif
here's the pickup code:
private void pickUp(Transform interactorTransform) {
var pickUpAnchor = interactorTransform.GetComponent<PlayerInteract>().HoldItem(this);
if (pickUpAnchor != null) {
grabPointTransform = pickUpAnchor;
transform.position = grabPointTransform.position;
transform.parent = grabPointTransform.transform;
rb.isKinematic = true;
rb.useGravity = false;
}
}
What's the actual issue?
The book is properly being parented, it's moved, kinematic, gravity etc..
its not though thats not where the anchor is set
when the player moves away, the book doesn't move with it
What's not?
Do you've got any other scripts on the book that moves it?
If camera moves then the object should be moving - assuming the hold point moves and isn't some object in the scene with a position constraint.
this was a fresh scene with just the two things, no other movement is happening on the book
Have the hold anchor selected and see where it is in the editor when moving the camera
yeah thats the gif I sent
I don't know much about your interaction system - seems obvious but I'd rather not make assumptions. Log this in pickup for verification please: cs Debug.Log($"Self: {name}, Target: {pickUpAnchor.name}", pickUpAnchor); Debug.Log)$"Grab Point (?!): {grabPointTransform.name}", grabPointTransform);I'm assuming the book was this object, pickup anchor was a reference to some unknown that was returned by the hold item method and that grab point is the hold anchor object.
The gif would suggest that the script is on the hold anchor though - relative to the gif (seeing the scene tools would be nice as well).
Prior to interacting with the book, the position of selection gizmo had moved below the camera.. why? 🤔 Anything funky in the scene or on the hold anchor object that we should be aware of?
the hold anchor is just a transform, it doesn't have any scripts, the root object of that tree, the Player object DOES have a rigidbody if that does anything, but otherwise the only scripts in the scene is a player controller, camera controller for looking at the mouse, and the interact scripts, the function I sent, is on the item itself apart of an 'Item interactable" component, the player has an interaction controller that looks for interactables and invokes their interact function, the item just calls that pickup script. The holditem is just a check to see if the player is already holding something, it calls back into the interact and if it comes back with a transform that means the player isn't holding anything so go ahead and assign this item. I just started up unity so im adding those debug logs rn
yeah im getting the right values backhttps://i.imgur.com/tQ20faO.png
Comment out the grabPointTransform = pickUpAnchor line and see what happens.
That would be the only line that would likely be evaluated elsewhere and do something abnormal. Other than that, the function is simply moving the position of book and setting it's parent to the anchor point.
I'm assuming the rigid body reference is the book's due to it no longer abiding by gravity and being kinematic.
Only other potential culprits would be whatever the HoldItem method does and anything else before and after the pickup method was called.
so it seems, like...so the movement maps to my mouse movement, but not to the WASD movement, the movement is split on the camera and the player, but its all in the same nested gameobjects, I'd expect the book all the way at the bottom to inherit both sets of movment. When the object isn't picked up the holdanchor transform tracks both
I did change the script as you said, and it didn't do anything, the assignment itself seems to be totally fine, its just the movement
how do you stop colliders giving firction between eachother
physics material
cheers
I'm looking for a way to assign a few unchanging variables to a game object.
for example, if I have a bunch of card objects, (basically a bunch of clones of the same thing) but I want a way to add a couple descriptors that other scripts can read, i.e., suit and value.
just make it public then they can see it?
the value isnt shared between each clone unless its static
They dont have any scripts on them, all of their functions are controlled by a single script
if you want other scripts to read data from another component, use a property with get-only access . . .
then make a script that goes on each of them
or you would have to store all variables in a list or something but thats just stupid
wouldnt that be clunky? would that affect performance?
thats not clunky, thats the way to do it
Makes sense
Ive heard that there are certain types of scripts that you use just for holding information
if its a card, then each card needs to hold what colour, symbol, number it is
you cant just store that all in 1 script
trying to code but there is like no pop ups or auto finish
trying to write OnTriggerEnter and nothing is there
ScriptableObjects? thats not really what you want for this though
whats keeping me from adding my blender objects? literally my first time using this sorry
!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
• :question: Other/None
!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
• :question: Other/None
i cant drag it in
type OnTriggerEnter
i have already done these things that it says
the problem isnt writing the words the problem is there is no autofinish like usual
what are you trying to drag where
the drivers_cab into the scene
i would find a tutorial on how to import blender models to Unity . . .
i already tried doing what it says and it isnt working
looks fine to drag in
it worked before so im confused why it doesnt work now
oh my dumbass was in game view not in scene
did you set your IDE in preferences in Unity?
yeah
did you follow every single step or just the first one?
why would you be dragging it like that anyway 😂
just drag it into the hierarchy
man its my first time using this
if you are talking to me
yes i followed all of them
there was like 3 things that could fix it and none worked
it happend last night and i fixed it then but i just got on again and it is broken
If I nest my if statment too much in my update/fixedupdate methode will the game lag? If yes is there any way to fix it like running both code independently?
not really, depends what your doing
nesting shouldnt hurt performance, but it will absolutely make your code unreadable
best not do it
I’m just setting up a code that will check if my dash/run status is true. I was thinking that this might hurt my performance.
depends what your doing you can just do if(!something) return; i heard this is better
and dont nest
I put the whole dashing script on a separate methode. I’ve seen someone make a separate script just for dashing but not too sure how to summon a methode from another script as I keep getting errors
so you need a reference to it
That’s cool thanks
Do you actually have a performance problem?
Nope it’s a completely new game. I’m just worried that in the future if I put too much if if if it will break the game.
also if you are doing this
if(Dashing)
{
if(running)
{
//this is wrong
}
}
this is wrong and can be shortened to this
if(Dashing && running){
}
think about how you can avoid using ifs completely
but as stated before, nesting shouldnt cause performance problems but will make your code unreadable
thats not nesting
Thanks I’ll try my best
Well, you have been answered already - it doesn't affect performance. You shouldn't worry about that unless you have an actual problem.
I mean in the future
I got it thanks guys
Because my code will involve a lot of combination of keys to summon a attack. But as someone mentioned I could just use &&
If you're on windows, you can win + shift + s (I believe) to crop a part of your screen and copy it as an img rather than taking a pic manually and uploading it
Ok 👍
thats if you have the snip tool
which should be installed
I have it but I don't remember downloading it ever, is it not a default program?
yep i have it despite never downloading it
once again whats the workaround for running code in onvalidate that unity doesnt like
i remember it was writing another function inside onvalidate something
ok delaycall found it
The workaround is not to run such code in OnValidate.
onvalidate is nicest of unity functions as it runs whenever i need it to run
If you need to do some editor only logic unrelated to valiation, you should use a custom editor/inspector
Not entirely true, depends on case, but a single layer of nesting can be acceptable. Consider this ```
if(dashing && running){...}
else if(dashing && swimming){...}
else if(dashing && flying){...}
...
In this situation I think it's better to nest those ifs in a parent if(dashing)
But of course the "right" way of doing it is to make separate OnDashing() method and do the checks there, or to use enum
The docs should have that covered.
how can i centre my ai in the middle of the model?
Either take your model back to blender and change it's pivot point, or have the agent on a parent and offset the child model however you like.
ok thx
Not sure where to ask this, but here goes:
When I start my scene the DDOL Canvas can't find the camera anymore. Which is strange, because prior to playing the reference is set correctly. The camera also doesn't show in the Render Camera dropdown anymore nor can I set it in code using camera = Camera.main;
I looked at the documentation, but didn't see any warnings about DDOL Canvasses. Am I missing something?
Video for reference (EDIT: Apparently you don't see the Unity dropdown in the video, but it doesn't have any options for camera's. Non-DDOL Canvasses work fine btw)
hi, my ai isnt working for some reason and i dont know why?
make it work
then you need to do it properly !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.
but the problem i see is
your ai has nothing to follow
possibly thats the problem
i dont think so
i think so, look at the error
If your code shows an error, that's a major red flag. Try and fix that first.
Also, if Unity encounters an error while executing code, it doesn't execute the code after it (without explicitly telling you). So if your second AI should work, maybe it doesn't because your code isn't even being executed due to this error occurring first.
ok
UnauthorizedAccessException: Access to the path '...' is denied.
Trying to access a filepath. And also create a random txt file to test with but seems like I can't.
The path i'm pointing it to should be within the Assets folder.
Ok doesn't seem like i can read/write at all even if it's within the project.
Make sure you're not confusing relative paths with absolute paths.
You can
Directory.Exists returns true though.
Well, the error talks about authorization.
Not about existance/non existance of the path.
If you need actual help, you should provide more info on the context and error details.
Here's the error.
UnauthorizedAccessException: Access to the path 'path' is denied.
The path is within the assets folder. And uses absolute path which i copied from the file explorer in windows 11.
error details. Not just the error message.
System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) (at <c0b7b90d34a54066a7234dad69255116>:0)
System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options) (at <c0b7b90d34a54066a7234dad69255116>:0)
(wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions)
System.IO.StreamWriter..ctor (System.String path, System.Boolean append, System.Text.Encoding encoding, System.Int32 bufferSize) (at <c0b7b90d34a54066a7234dad69255116>:0)
System.IO.StreamWriter..ctor (System.String path, System.Boolean append) (at <c0b7b90d34a54066a7234dad69255116>:0)
(wrapper remoting-invoke-with-check) System.IO.StreamWriter..ctor(string,bool)
System.IO.File.CreateText (System.String path) (at <c0b7b90d34a54066a7234dad69255116>:0)
Assets.Scripts.ExternalDependencies.Editor.ExternProjectList+ExternProjectListEditor.OnInspectorGUI () (at Assets/Scripts/ExternalDependencies/Editor/ExternProjectList.cs:72)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass76_0.<CreateInspectorElementUsingIMGUI>b__0 () (at <043e10ec4a0f4999a2729072194b9cfe>:0)
What path is it exactly?
show the full code
D:\TechnicalProjects\Unity Project Stuff\Plazma Haze\Assets\Scripts
if (GUILayout.Button("Validate Dump Paths"))
{
Debug.Log($"Dump: {Directory.Exists(Target.dump_location)}");
File.CreateText(Target.dump_location);
}
Asking a fuller code than this, it's really just a scriptable object with a custom editor that has this button.
Can you log the Target.dump_location before the File call?
why are you using the same variable for Exists and CreateText, they take different values
if (GUILayout.Button("Validate Dump Paths"))
{
Debug.Log(Target.dump_location);
Debug.Log($"Dump: {Directory.Exists(Target.dump_location)}");
File.CreateText(Target.dump_location);
}
School wifi. 🗿
you are missing a file name
Did you check the C# docs of File.CreateText and what errors it throws when?
File.CreateText(Path.Combine(Target.dump_location,"MyFile.txt"));
Steve is correct. And you can see that the docs explicitly say that path needs to be a file to be opened, not a directory.
If it just want a file name, i wish it didn't use UnauthorizedAccessException i thought it implied that I don't have permissions the entire time.
but that is correct. you are trying to treat a folder as a file, that is unauthorized access
Anyways, I think I got it, thanks.
I agree, that they could've provided a more specific error for this case. But then again, it could've been an actual file without extension.🤔
Also you should use Application.dataPath rather than hardcoding paths to the Assets folder
Yeah, i've just been randomly searching and trying stuff.
string dirName = Path.Combine(Application.dataPath, "Scripts");
string fileName = Path.Combine(dirName,"MyFile.txt");
My first assumption was some kind of bug in unity and went off there.
But that was not unity api that you were using.
!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.
i need help, i am trying to figure out how many enemies are in the scene and limit is so enemies are only spawned 1 at a time. in my game manager script i have this line of code
// public int enemiesAlive=1;
then in my spawnmanager i have this code
// if (Time.time>i && gameManager.gameisrunning && gameManager.enemiesAlive < 1)
{
i += 5;
Instantiate(enemyPrefabs[Random.Range(0,2)], randomspawnpositionenemy, Quaternion.identity);
gameManager.enemiesAlive++;
}
which checks if there are no enemies on the scene and then it spawns and add ones to enemies alive
then in my detectcolissions script i have this code where when the projectile hits the enemy it should subtract enemies alive and then surely it should spawn again? but thats not working
// private void OnTriggerEnter(Collider other)
{
if(other.gameObject.CompareTag("Enemy"))
{
Destroy(other.gameObject);
Destroy(gameObject);
gameManager.enemiesAlive--;
}
}
To start with. simply saying something is 'not working' is not helpful.
Add some Debug.Logs to your code to see what is happening then come back with your updated code and a screenshot of the console
If the check is in Update method running every frame, "i" will be always greater than time.
Unless your frame takes longer than 5 seconds
nonsense
Why, let me see one more time...
i is only updated when it is < Time.time
Also, you're probably confusing .time with .deltaTime
sorry something came up so ill have to go back to this some other time but i shall take your advice thx
Ah you right, didn't see the enemiesAlive++ there, sry
can anyone help i delted scene by accident and now i can only see from my player model
Omg need another coffee nvm
not a code question, do not cross post
sorry
Sorry for the long post but I’ve had this issue for over a week now and I’m at my wits end. I so desperately need this to work (school project), so any help would be incredibly appreciated.
In my game you’re a pawn on a chess board (100 tiles that are 2x2) where tiles will fall at random on player collision and enemy pawns track you and knock you back on collision.
I’ve made the PlayerMovement so that you snap into the center of each tile when you move using a move point. It works when moving around, but when other pawns knock into you more often than not the tile alignment gets screwed up so that the player ends up between 2 tiles instead of in the center of 1 tile without the possibility to align to a center. This breaks the movement scheme and basically the game loop.
My latest attempt was to place invisible spheres in the center of each tile (that I’ve added both a “CenterPoint” tag and layer to) to make the player snap to the closest center point while being pushed via a spherecast, but since it’s all very new to me I’m not surprised I haven’t been able to make it work yet. Is anyone here able to help me? The script in question: https://gdl.space/cijapakade.cs
!code. Please use a paste site
📃 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.
copy/paste to the paste site. Save. Paste the link given here
My bad. Edited.
first thing, never mix rigidbody and transform movement. chose one or the other
Gotcha, I'll keep that in mind. Since this issue only occurs when enemy and player collide, think that could be a factor?
absolutely
tbh, with what I see of your setup and gameplay I see no need for rigidbody movement at all
Using transform movement has been the only way for me to get the movepoint-movement to work. DIdnt know it could screw with rigidbody though
Interesting. I'll see if I can refactor it without breaking everything.
Lerp or MoveTowards are your friends
hi i have a question, for some reason there where no errors and out of knowhere there where some errors i dont understand
using System.Collections.Generic;
using UnityEngine;
public class Poppetje : MonoBehaviour
{
public Rigidbody2D myRigidbody;
public float flap;
public LogicScript logic;
public bool playerIsAlive = true;
public AudioSource audioData;
// Start is called before the first frame update
void Start()
{
logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<LogicScript>();
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space) == true && playerIsAlive == true)
{
myRigidbody.velocity = Vector2.up * flap;
}
if (transform.position.y < -12 || transform.position.y > 12)
{
logic.GameOver();
playerIsAlive = false;
audioData.Play(0);
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
audioData.Play(0);
logic.GameOver();
playerIsAlive = false;
}
}```
you have 2 of this script
probably by mistake
and some tips for your code.
== true isnt needed, you can avoid the FindGameObjectWithTag by just making a static instance in your LogicScript
public static LogicScript Instance;
void Awake() { Instance = this; }
and make a method called PlayerDead or something instead of repeating the same play audio and changing bool and calling method 3 different times
thnx
jeah i started yesterday with unity and followed a absolute beginner tutorial hahah
yeah can tell, you dont have to do what i said now if you want but just keep it in mind for the future as it would be the better way of doing these things
thnx
I'll have to look into how to use that here. Tried removing rigidbody and some feeble attempts at scripting custom gravity etc and to little surprise it's wonky and breaking everything 🫠
It's possible that using CharacterController may be more suited to your needs
And still keep the snap-to-grid movement? Spent a lot of time implementing it this way but at this point I wouldn't mind throwing everything out just to make this work
tbh snap to grid movement is much more suited to transform or CharacterController movement than it is to Rigidbody. So either should work
hey, im trying to make a nonogram game for mobile, everything seems to be working correctly on unity's simulator phones, but once i build and run the game on my personal phone, the main grid object isn't rendering the grid, why that could be? i was getting some errors about Adaptive Performance, but it told me to install Samsung (Android) providers and so i did, but still no grid on my phone
How are you rendering that grid?
the grid object is creating 5x5 grid out of gameobjects "tile"
tile is just a gameobject with square sprite
You'll need to provide some more details. Maybe screenshots of the setup and what it looks like in the editor and in the build.
this is how it looks in simulator in unity, but on my phone only the "capsule" on the bottom shows up
Take some screenshots of the setup. The hierarchy, camera, tile objects, etc..
hierarchy contains only the camera, grid, tile and clue tile (capsule is just a sprite for now (no code))
tile
cluetile
grid
camera
Do you guys have a script to buy presonage or unlock it?
yes
What do the scripts on the following objects do?
- Camera
- grid object
- Tile object
Camera:
checks for device's aspect ratio and check's grid's size to adjust camer orthographic size
Grid:
instantiates gameobjects Tile to make a grid,
instantiates gameobjects ClueTile that show the clues around the grid
moves the grid a bit depending on it's size (to center it on screen)
Tile:
checks if it has been touched and if so then it changes it's color
full code is a bit long so just the descriptions, if u want me to post the code, will do
There could be a bug in:
- adjusting the camera size
- instantiating and repositioning the objects
- adjusting the tile color
You should test a bare minimum setup without doing the above-mentioned things to see if the objects are visible. If they are, start reenabling features one by one until the issue occurs. Then just debug it.
will do, but wouldn't it also break on simulator? i've checked numerous devices and screen resolutions
Then there is something different between the simulator and your actual device. Otherwise it would work.🤷♂️
There's also a chance that you're using some API that doesn't work on an actual device or works differently.
The simulator is only for simulating aspect ratios. It doesn't emulate the whole device on the PC.
ok, thanks
Hi, I am kind of bit confused here. Why debug.log in IEnumerator is printing first than the one in sequence.Onstart. Is there a way to execute tween in current execution order?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class Follower : MonoBehaviour
{
private void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
PlayAnim();
StartCoroutine(Example());
}
}
IEnumerator Example()
{
Debug.Log("Function started");
yield return new WaitForEndOfFrame();
}
Sequence sequence;
public void PlayAnim()
{
sequence = DOTween.Sequence();
sequence.OnStart(() => { Debug.Log("Sequence started"); });
sequence.Play();
}
}```
private List<GameObject> supports = new List<GameObject>();
// Start is called before the first frame update
void start()
{
foreach (Transform child in transform)
{
if (child.name == "Support")
{
supports.Append(child.gameObject);
}else{
print(child.name);
}
}
}```
i have this code that i hoped would just get the children named support but the section inside the for loop doesnt run (`supports` is empty and it doesnt print `child.name`)
the script is attatched to a gameobject. which gets activated when i rclick and deactivated when im not rclicking
does anyone know why its not giving me the transform of my support
Probably because dotween updates later in the frame.
start != Start
You'll need to research how the asset works to answer that question.
oh.. thanks
still a nope, capitalized the S
the script would need to be attached to Platform because it only gets direct children
it is, my bad for not making it clear
oh wait i attatched it to the wrong one 💀
i ment to attatch it to platform
its working now :) ty
What is presonage?
I did google it but it's a mess
maybe a character? personage
Let's discuss it better in a private message
No thank you
Let's translate a word if we don't know it in English
im trying to make a script that extends the support for this platform to the ground, but there is always a gap. does anyone know why?
the support is a gameobject attatched to a platform gameobject
public class SupportExtensionController : MonoBehaviour
{
// Update is called once per frame
void Update()
{
foreach (Transform child in transform)
{
if (child.name != "Support"){ continue; }
RaycastHit hit;
if (Physics.Raycast(child.transform.position, Vector3.down, out hit, Mathf.Infinity, LayerMask.GetMask("Ground")))
{
print("HIT SOMETHING!");
print(hit.distance);
//set the scale of the support
Vector3 scale = child.transform.localScale;
scale.y = hit.distance / transform.localScale.y;
child.transform.localScale = scale;
print(child.transform.localScale.y);
//set the postition to the middle because unity scales the cube to both directions
Vector3 loc = child.transform.localPosition;
loc.y = -hit.distance * .5f / transform.localScale.y - .45f;
child.transform.localPosition = loc;
//just a visualisation to see if its working
Debug.DrawRay(child.transform.position, transform.TransformDirection(Vector3.down) * hit.distance, Color.yellow);
}
}
}
}```
Looks like something to do with your scaling on the y
yeah since the gap increases with scale, im having trouble figuring out what though
Not entirely sure but the scaling should be the distance to the floor divided by the original object's height.
that is it right now
Pretty sure local scale y is a normalized value?
Or rather it's scale instead of the object's actual height.
maybe its because im moving the support to account for the scaling going up, so the raycast starts from lower after moving it the first time?
So if the object is 10 units tall and the floor is 15 units away, you'd scale the object by 1.5 times in the y.
thus it thinks the distance to the ground is lower and it lowers it scale?
Log the value of the scale and see if it's what you think it is
I tried to create an enemy library for all of my enemyUnits and for some reason when I start the game it gives me the Object refrence not set to instance of an object. any help?
Formula would be (relative to the height of the object) current/original = scale. What I believe you've currently got is current/scale = scale
Show the actual error message
It would tell you where the error was thrown
And what line is 60 of the battle script?
Your image crops do not show line numbers
its says 60 but when I click it it sends me to line 146
which is the line that summons the SetupBattle method
Which variable is throwing the nre?
lovely how you cut off the lines.
post code properly with links at least
Either tell us or simply post the entire script
!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.
where did you assign enemiesLibrary
That would be the declaration
thats declaring not assigning
It's null as it is unless you've assigned it a reference/value
You go to the store with "I want apples" and then you leave the store..
you never got the apples
the object that contains the array is null
who knows if the array is even not null
if its not public/SerializeField private
and you did not do = new () chances are its null too
Maybe. Either that or the member being accessed.
I think I assigned it in the inspector?
here?
if it on a gameobject then sure its no null
Unity automatically new() a serialized list/array when on an instance
How though, isn't it private non serialized?
Unless it's a value type 
I attached to the battlesystem the Enemylibrary Script
So I'm doing this
animator.ResetTrigger("Attack");
animator.SetTrigger("Attack");
for making the player attack, but the problem is, that if I press the attack button twice, it will "queue" the animation again, even if I just press the button twice in a row really quickly by accident
Things that can throw null.enemiesLibrary.Length//error cannot access enemies library enemiesLibrary.null.Length//error cannot access length
didn't I do it already?
you never assigned enemiesLibrary to BattleSystem , so you can't access your specific array
(the code knows what to access cause its all declared, but you're missing the specific one you want to work with hence null ref)
so I should remove the enemies library compoenet make the EnemiesLibrary public and reattatch it right?
you dont need to remove it
just assign it as shown in the link sent to you
doesnt need to make everything in the inspector public , only when you want to access it from other scripts
yep, it halves every update 😩
[SerializeField] EnemiesLibrary enemiesLibrary would suffice
then **assign ** it (drag n drop)
where you put EnemiesLibrary components is your discretion
Reminder that what was shown is implicitly privatecs [SerializeField] private EnemiesLibrary enemiesLibrary
it doesnt let me drop it tho
which one are you dragg in
The denominator of the formula needs to be an unchanging value and that of the object's original height - relative to #💻┃code-beginner message .
Not the object's scale (a ratio) or whatnot but the actual height.
Im new to developing unity for android, how do i save data to android ? (I only used Windows so far)
Like i need to create a hanami.db file and read / write to that, also create a (cache) folder and save images in there, how can i do that ?
Found it Application.persistentDataPath, just like in Windows lol
You'd just save like you'd normally would on a PC but probably using the location https://docs.unity3d.com/ScriptReference/Application-persistentDataPath.html (note that the location on Windows would be in the registry - nasty unwanted dumping)
"the location on Windows would be in the registry", what ? Thats completely wrong, its in AppData ?
Yeah looking at the link it even tells you:
Windows Editor and Windows Player: Application.persistentDataPath usually points to %userprofile%\AppData\LocalLow<companyname><productname>
Oops, I was thinking of player prefs, forget the second.
yeah i wouldnt use that for anything anyways
rather do a settings.dat or save them in the .db
done, it works now thanks alot :D
you do realize you just wrote the same exact code i did with some else if statements?
not sure what you are trying to get at
using else if statements is not nesting by the way
Yes I do. And no, it is not, my point was only that nesting is not always that bad in some simple situations
In that code I posted first snippet is just as readable as the second, without the need of rewriting "dashing" boolean 3 times
- now I realized that I posted only "else if" version, but I bet you get the point that nested equivalent is acceptable
i'll typically chose the most important boolean and nest other conditionals within
if(dashing)
{
if(running){
}
if(flying){
}
}``` anymore than that tho and i start reevaluating my logic
breaking it up into switch statements perhaps
For me that is perfectly okay UNLESS you add another layer of nesting in these sub-statements
i dont like using this && that && otherthat
too many &&s to read easily..
imo nesting just a bit is easier to follow
ya, thats what im saying. i wont go any deeper than 1 or 2
especially not 3
statemachines come to mind if ur nesting that much lol
but i suck at those so far
can only muster up a basic enum one..
Yeah, enums are the right tool for such things
if (Physics.Raycast(feet.transform.position, Vector3.down, out hit, Mathf.Infinity, LayerMask.GetMask("Ground"))) {
canJump = true;
Debug.DrawRay(feet.transform.position, transform.TransformDirection(Vector3.down) * hit.distance, Color.yellow);
}
im raycasting down, to check if the player can jump. this works on my terrain, however it doesnt work on my other gameobject. does anyone know why the raycast phases trough?
both the ground and the platform are layered on ground
probably begins within that object
you forgot to assign it to ground layer?
or its not set to check for it
so my ray cast origin is just too low?
i put it higher and it worked :D ty
nesting in of itself is a bad habit and can make your code unreadable, and im not even saying doing a ton of else if's is any better to but for his specific use case that was the appropriate way to go about it.
using an enum or a private void Dashing() is definitely way better for readability
i have a really bad habit of using a ton of &&'s 😅
but other than that, nesting for only 1 line is okay for readability
first time messing with animations, what do i do to add this bool paramater into the animator? ive set it so the bool is true when im moving, which works fine. but im not sure how to add that to the animator so that it actually affects the animation being played, if im wording it right
i want the animation to play when isRunning is true
i would !learn how to use the animator, and anything animator/animation related goes in #🏃┃animation
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
oh right oops too used to talking in here
Could I have a list of UnityEvents?
Can you have UnityEvent serialized without a List? In this case you'll be able to serialize it inside of the List
if(currentInteractable.isHoldInteractable)
{
if(Input.GetKeyDown(KeyCode.F))
{
Debug.Log("Started holding interaction");
currentInteractable.OnStartHoldInteract?.Invoke();
}
if(Input.GetKey(KeyCode.F))
{
Debug.Log("Holding interaction");
currentInteractable.OnHoldInteract?.Invoke();
}
else if(Input.GetKeyUp(KeyCode.F))
{
Debug.Log("Let go of interaction");
currentInteractable.OnStopHoldInteract?.Invoke();
}
}```
my problem is that suddenly the isHoldInteractable can become false
and it will never reach the last else if statement
which calls the OnStopHoldInteract event
how can i also call the OnStopHoldInteract event if i was holding F and suddenly isHoldInteractable became false
i did this
i think it works let me check
yeah works
does anyone know how i can prevent animations from overriding rotation?
i cant find anything about it online
if you double click on an animation and right click on the rotation property, you can press remove properties to remove all rotation to said animation
also
next time go in #🏃┃animation
oh ok
entities.Add(Resources.Load<Entity>("Prefabs/Entity"));
entities[i].transform.parent = this.transform;```
When I load prefabs as a script no GameObject is created in the hierarchy and I cant access the transform. Is there a way to make this work?
```GameObject entity = Resources.Load<GameObject>("Prefabs/Entity")
entities.Add(entity);``` this also does work
Resources.Load just loads a reference to the prefab. you still need to instantiate it if you want to put it in the scene
regular c# arrays are more light-weight and faster than List<>, right?
yes
less stuff
I think its about the same
List iirc is wrapper to array
define "light weight" and "faster" because they have the same time complexity for performing the same actions because a List<T> is just an array with some extra functionality (like being able to be resized)
yes but it still uses more ram
it has two extra ints
however if you dont know how many elements in a array will be added, its better to use list
otherwise you will be resizing the array copying and so on
less is always better
depends on the situation tho
if you are allocating so much that 8 extra bytes makes any amount of difference, then something is seriously wrong with what you are doing
it is always better to use list if you dont use the features of List
thats what i want to say
there is nothing wrong with that
why add extra stuff to your code that you wont use
there is no "better" in any case. use the correct tool for the job. a list is not better than an array, nor is an array better than a list.
this pretty much shows when is the other one better than the other
but yes what you said is sort of right, depends on the situation as i said
i'm trying to make snake, and i'm looking for a way that the food doesn't spawn on the snake itself. here is the spawn code:
public BoxCollider2D playArea;
private void Start()
{
RandomizePosition();
}
private void RandomizePosition()
{
Bounds bounds = this.playArea.bounds;
float x = Random.Range(bounds.min.x, bounds.max.x);
float y = Random.Range(bounds.min.y, bounds.max.y);
this.transform.position = new Vector3(Mathf.Round(x), Mathf.Round(y), 0.0f);
}
private void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Player"))
{
RandomizePosition();
}
}
does anybody know what i can do that it doesn't spawn on the player
i tried physics.checkbox but wasn't able to get it to work
depends on how you coded the player, is the movement a grid like system or free movement like snake.io
that information isn't even accurate. for example, List.Count is o(1) which is the same as Array.Length because List.Count is literally just reading the value of a field. List.Contains and Array.Contains are also pretty much identical considering List.Contains just calls Array.Contains
player (leaving out the enable and disable stuff)
private void FixedUpdate()
{
for (int i = _segments.Count - 1; i > 0; i--)
{
_segments[i].position = _segments[i - 1].position;
}
this.transform.position = new Vector3(
Mathf.Round(this.transform.position.x) + _moveDirection.x,
Mathf.Round(this.transform.position.y) + _moveDirection.y,
0.0f
);
}
private void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Red"))
{
Grow();
Debug.Log("NOMNOMNOM");
}
}
private void Grow()
{
Transform segment = Instantiate(this.segmentPrefab);
segment.position = _segments[_segments.Count - 1].position;
_segments.Add(segment);
}
just so you know i didnt make that list but found it on stackoverflow, and it is mostly meant to just show in what cases to use it
So an array which always has a length of 64, and consists only of single digit integers, is better than list?
yes, definility. However if you insert new elements so like add a new interger and make length 65, 66, 67 and so on List is better
and the information that provides is inaccurate. I already know the use cases of Lists vs Arrays, and in most cases it doesn't really matter which is used. but you cannot claim that one is better than the other at something when they do the exact same thing. verify your sources next time.
alr so, you store the segments in a List with each their position right, on the RandomizePosition function i recommend you do a for loop over each segment then check if the position is equal to segment if so create a new position and try that one.
However you need to a look for float precision errors, so either you use Vector3Int or round them up everytime checking (Vector3Int is better if you are going for a grid like system which seems like it)
there is no "better" here. if you need a collection whose size will never change then it is more correct but not better to use an array. using a list for that is also perfectly fine and literally the only difference you will see is that extra 8 bytes in memory.
The source is from stackoverflow with a comment of 153 upvotes, and i showed it just to show when to use an array
so in the food script i'd do a for loop going over the segments in the player script, with if those don't overlap that it can spawn. did i understand you right?
why are you seperating more correct and better for what reason? just say better, i dont understand why make it too hard to understand for him
anyone can post on stackoverflow. just because you see something on there does not mean it is correct. you can literally read the source code and see that many of those operations are exactly the same on a list when compared to an array.
also, is there even a noticeable difference at all?
yes and as i said use a array/list of Vector3Int instead vector3's which is what i am guessing you are using
no, that is my entire point. you will not notice any actual difference between the two for what you've described. it's just considered "more correct" to use an array for a collection whose size never changes. but there is literally no harm at all in using a list instead
yeah okay
right. i'm using mathf round instead to round it at the moment. i'm going to look into it. brb
depends if its performance critical or not, if its not its just better code.
what about using byte instead of int? would that have a noticeable difference?
Does anyone know why my particle system is visible over my UI elements
again it depends on your situation, however bytes are less ram.
the difference will be in amount of memory used and the available values you can assign.
yeah, but if i am 100.000.000% sure that my exceed 127 ( or 255), wouldnt it then be the best option to use sbyte or byte?
you are way overthinking this mate.
hahahahah
What are you building anyway actaully, something performace critical?
Procedurally generated city...
How are you generating the city?
On a monobehavior class or what
nope, probably doing it in the worst way possible hahah, but im basicly just making it up as i go, it is gonna be tile-based, with 1 chunk being 8x8 tiles rn
fun fact, but it is more performant to use an int than a byte (with regards to CPU access). but also the performance difference is so fucking small that it realistically does not matter except in the absolutely most performance critical applications
Just use int for know get it working, if you want it really performant than just go on the performance side
produceral stuff are performance critical
lol not that much
ah yes, render distance definitely has anything at all to do with their procedural generation algorithm
I am guessing he is building the mesh with scripts or not?
Like voxel games
luckily i dont - im super into low-res stuff like the early half-life games
mate, this is the beginner code channel and this person was asking about using a list vs an array. they aren't doing that
Oh than, dont worry about int and sbytes.
alr bro my bad, i lost track of time 😂
this is my life now...
why no for loop
because this looks cool 😎
i aint even saying anything, that chad code you know
them nerds be using for loop 
your condition is wrong, unless of course you never need to access the first tile for whatever that is supposed to be doing
oh thats true hahah i missed that one
the other for loop goes from 0 - 63 so that one does access it, but might as well fix it rq haha
yes i have 2 for loops doing the same thing, just in different directions :0
I just watched CodeMonkeys Video one a Grid building system and i want use it but i have some questions
Is the "Heat Map" scripts required to make it work, i only ask this cause in his powerful "Powerful Generics" video he talks and uses them
The Generics from "Powerful Generics" required/helpful to use
Since to put this into a 2D game, is all i have to do is put 2D instead of 3D and Y instead of Z
i only ask before hand so i dont break anything that ive made so far
https://www.youtube.com/watch?v=dulosHPl82A&t=101s
✅ Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=dulosHPl82A
🌍 Get my Complete Courses! ✅ https://unitycodemonkey.com/courses
👍 Learn to make awesome games step-by-step from start to finish.
🎮 Get my Steam Games https://unitycodemonkey.com/gamebundle
✅ In this Unity Tutorial, let's make an Awesome Grid Building S...
hi, i want to have a small animation when i click the sprite, but when I click 1 time it loop the animation and if i click again it just stop (it's for a clicker game)
well, i can't answer exactly but i wanted to at least throw out something helpful..
nothing wrong with experimenting and building out systems in order to fit what u need..
but experimenting is just part of that sometimes..
whatever you do.. before implementing a system like that.. I'd make you a backup copy of ur project
theres no need to having the worry if you'll break something or not.. not a fun way to develop imo
just set the animation clip to not loop? oh and theres this
i made this yesterday for someone while testing the Animator's Trigger parameter
we figured out that we could use AnyState and transition from that to our animation..
then the trigger will interupt the animation and restart it
I can't find the option for looping
click the animation clip in the project window
and in the inspector there should be a parameter called isLoopLoop Time
or something like that
and for my transitions i mark hasExitTime => false (b/c i wanted my clip to interupt itself)
if it was set to true.. my clip would have to finish entirely b4 the trigger would play it again
altho.. that may be something you want.. for me it wasn't just wanted to throw that out there too
oh yeah thanks, now my problems is that it play the animation every 2 click idk why
ya, that sounds more like a logic/ code issue probably
you can barely see.. but my logic is calling Debug.Log("Messages"); soo i know whats happening
u should probably do the same..
log when u click
log when u change the animation trigger
and so on.. to see if maybe something stands out as being wrong
ok o:
if u cant figure it out then come back and re-ask ur question.. and share/link your !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.
someone will surely help ya get it sorted out
now it make the whole animation and reset (as i want) but it's not fast enought even if the animation is fast
using UnityEngine;
using TMPro;
public class ClickHandler : MonoBehaviour
{
public int score = 0;
public TextMeshProUGUI scoreText; // La référence au texte UI
private Animator animator; // Référence à l'Animator
void Start()
{
// Récupérer l'Animator attaché au sprite
animator = GetComponent<Animator>();
}
void OnMouseDown()
{
score++;
scoreText.text = "Score: " + score;
// Déclenche l'animation
animator.SetTrigger("PlayAnimation");
}
}
on ur transition u can change the transition times
i bet its b/c the transition is taking soo long..
so it makes the animation appear to take longer
should set it to something like 0 to make it instant/snappy
ya, not really much here.. looks fine to me..
- Start -> Get Animator
- OnMouseDown -> add 1 to the score, display teh score, and Trigger
PlayAnimation
now my animation is perfect and don't loop but it's played every 2 clicks XD
how can i access another gameobject's script's variables through a script?
get a reference to that component
thanks
i was told to go here for my help so
Having a configured IDE is required to get help with your code here. Follow the instructions that were already provided to you in #💻┃unity-talk
okay
i think i understand what an IDE is
is an IDE visual studio?
@slender nymph
im going to take that as a yes
hey so for my game i have a gamemanager that is in the main menu scene and just has it so it doesnt destroy on load but if lets say i want lose and want to try again how can i make it so that game manager is still there since i dont think it will load the main menu again
if it is DDOL then the only way it will be destroyed at runtime is if your code destroys it. so just . . . don't destroy it
oh wait yeah im dumb nvm thanks
literally what is wrong, my camera should have the MainCamera tag
do i have to apply DDOL more then once?
You've likely declared your own class called Camera and it is trying to use that instead of UnityEngine.Camera
oh oops
because for some reason is works and doesnt get destroyed the first time i load a new scene but then it gets destroyed when i load another scene
hi I'm wondering if anyone can help I'm doing this tutorial https://youtu.be/rJqP5EesxLk?si=WduWLD8AcMMIAWwy&t=626 and I'm using the code private "PlayerMotor motor;" and while writing the script it gives me an error. for some extra context I have another script called Player Motor and I'm pretty sure it's supposed to be referencing that but I don't know why I am getting problems I've followed this tutorial really closely.
The first video in a series where we are creating a First Person game!
In this video we look at setting up our characters movement.
I've setup a Discord!!! and I would love to have you help me start up a friendly community where we can all help each other grow as game developers!
Discord invite link:
https://discord.gg/xgKpxhEyzZ
Can't wait t...
I've time stamped it at a specific time where the specific line gives me trouble
whats the error
show the error from ur editor console window , and send !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.
Does Screen.height and Screen.width return different values depending on where it's called?
Cause that seems to be the case. I had a bug where i'm using those two and had problems with getting the playmode window.
Since one is called inside Awake, and the other through some custom editor.
ok thanks
I'm certain that the latter is returning the height and width of the inspector.
yes
Can someone direct me to a good 2D Grid Building Turtorial, the ones I keep finding are always 3D or don't really do good job in explaining what's happening
there are tons on yt from what i can see if you look up unity 2d grid system
Yhea but they don't seem to do a good job in explaining how they did it, a good amount usually preemptively set something up before and and don't really explian it
Something I can follow so I can understand it, best if it started from scratch
You'll need to put some effort into researching the things that you don't understand in the tutorial. They expect some basic level of understanding from you.
I have some level of understanding, it's just when the pull out a who package out of nowhere and grab functions, it tend to be confusing
I already know how to make the grid, it's just making the ability to place building down and making it snap to said grid is the issue
!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
• :question: Other/None
What kind of packages are you talking about? If it's unity packages, then they have documentation. If there's something you don't understand about them, you should refer to the docs.
Hi guys.. I am doing the same for multiple variables in my game.. no problem at all changing their value using my Getter and setters.. but there is 1 variable specific that I am not being able to change AT ALL, the value never changes no matter what I do. private bool _isPlayerDead;
my get and set: ``` public bool IsPlayerDeadGetSet{get{ return _isPlayerDead; } set { _isPlayerDead = value;}}
I have other getters and setters in this same script and I am able to change their values or get the values from everywhere.. but this one I cant.. any ideas?
Just doesnt work.. the values never change or never get the correct information.
Debug it
already did all the debugs I could imagine
I am 3h now just to understand that and I just cant
hahaha should be soimething simple and its giving me a headache crazy 😦
I am doing a game for weeks and all going smooth.. first time I am stuck with something that supposely should be simple
and have been working so far for everything. crazy stuff
Did you try adding logs to the setter?
Debug.Log("Game Started: " + _gameManager.DidGameStartGetSet + " Player Is dead: " + _playerHealth.IsPlayerDeadGetSet);
That is the logger I have been using
This is not in the setter
A setter is just a method, you can add as many lines of code as you want.
oh ok makes sense
Debug the old and new values, and see if it's being set to values you don't expect
The game must be crazy, I have no where in the game to change it to TRUE now. And I created a method where I click a button.. that method is inside the same class. when I click the button the variable doesnt change. that is the button public void PlayerIsDown(){ _isPlayerDead = false; }
I mean, does it make sense? hahaha
inside the button with a debug says it changed, but debug for the variable itself .. doesnt change
what a crazy world.
You should use the property everywhere since you made one
You're still accessing the private field here, essentially bypassing the setter's logic (if you have some)
I dont, I removed everything everywhere. Well who knows. 3h already trying to figure it out something " Simple" and I got go sleep to work. will try to sleep I hate to sleep when I cant figure it out something hahaha makes me sleep anxious.. hahaha anyways ty guys
what do you mean?
You should be doing IsPlayerDeadGetSet = false instead, so it uses the property and runs your setter
but inside the same script, what is the dif from using _isPlayerDead = false; or IsPlayerDeadGetSet = false? wouldnt it be the same?
It would prevent the debug log from printing. Also, we don't know where else you might be setting it.
The second one would run all the code in the property's set accessor, which would log, and therefore narrow down where your bug could be
Basically, it interferes with debugging the property.
understood. Thank you guys will try more stuff with the info you gave me and see what I get.
I will check more tomorrow but sounds like a bug in the view.. when I have only 1 bug.log it shows the debug on the botton left.. the value there shows as not changed of this variable but shows other variables changing.. but when I open the debug tab it shows correctly as changed.
I will need to do more tests, tomorrow, thank you!!
What debug tab? Look at the console.
Why is a diagonal look jagged with the mouse but smooth with a joystick?
TriggerConstantAction is being called in update()
Hello, I debuted in Unity and I'm following a tuto to make a 2D game, only I have a problem and can't activate Game mode. Apparently, FadeSystem is not defined, despite the fact I reproduced the coding necessary and assigned the fade system. Can someone help me, please?
It says that the tag FadeSystem doesn't exist. Have you made that tag?
its not about the code, its about the Tag
Is there any way to mass place destinations for ai? Its on terrain and i was wandering if it can automatics adjust to the hight of the landscape
Not sure what you mean by mass place, but regarding the second question, you'd need to calculate the exact position.
i have big terrain and want to place a lot of destinations but i dont want to spent 10h doing it. Is there any faster way of doing it?
What kind of destinations? Sadly, computers can't read your thoughts yet, so you'll need to tell it what kind of destinations you need.
write code to do it
Like i have to place a lot o f ai destinations(just a empty game object) for the ai to pattrol to, but my terrain is big and i dont want to place all the destinations.
Place where/how?? Randomly?
you really don't need to do that, a list of Vector3's will do the same job
Are there any requirements for these destinations?
yeah, or ordered, it dosent matter
Then just place them randomly. Or better, fill an array with the vectors representing these destinations.
the terrain is realy big so i dont wanna place it manualy
you keep repeating that, we are not idiots
sorry, i am new to unity, and aint the best at english
so why can you not write code to do it?
well you have a choice, either learn how to do it or place them manually. there is no shortcut
ok thx
Place them randomly via code is what I meant.
oh, ok thx
Hi, how is it possible to turn an object as a child into a parent but its original position will not change?
copy the value?
I mean the original position to the preset position
No, when you put a child in a certain object via script, its relative position changes u know
The world position should still be the same. The local position would change, as it's now local to something else. I'm not sure what result you want but you can use this method and specify the 2nd parameter
https://docs.unity3d.com/ScriptReference/Transform.SetParent.html
I'm trying to bring the child to the parent through a script without its X Y Z changing (the child is a prefab)
This really doesnt make sense
If you're just setting the parent to null, the actual position of the object doesnt change. Just what you see in inspector is in local space
I have a base class with a virtual method, and that method contains a local variable
{
GameObject currentTarget = enemiesInRange[0];
}```
I then have a child class that inherits from that one, with an override method that uses that variable
```protected override void Attack()
{
base.Attack();
transform.up = (currentTarget.transform.position - transform.position).normalized;
}```
But in this case, the child class can't find the currentTarget variable. What could I change for it to work?
virtual protected GameObject Attack()
{
GameObject currentTarget = enemiesInRange[0];
return currentTarget;
}
protected override GameObject Attack()
{
GameObject currentTarget = base.Attack();
transform.up = (currentTarget.transform.position - transform.position).normalized;
return currentTarget;
}
hey, my game works in unity play mode, but on my phone i'm getting an error:
2024/09/15 13:19:51.090 20214 20256 Error Unity DirectoryNotFoundException: Could not find a part of the path "/Assets/Levels/levels5.json".
why is that and how can i fix it?
Are you trying to access a file at that path? The build does not have the same folder/file structure as the project.
yes
Well, that's not gonna work then
how do get to the file on mobile?
Reference it.
Or put it in Resources and load via resources.
Asset bundles and addressables are also an option
having some issues applying forces to instantiated prefabs. im on unity 2019.4.31f1, following brackeys' "how to make a game in unity" tutorial. i added a simple proc gen system for my obstacles, essentially i just have a separate object which instantiates a prefab at certain positions. the issue im facing is that when i try to add force to the rigidbody of any of those instances, the object simply doesnt move
the whole script is included below.
this is the function for moving objects
void moveSpawnedBlock(GameObject inst)
{
Debug.Log(inst);
Rigidbody rb = inst.GetComponent<Rigidbody>();
Debug.Log(rb);
rb.AddForce(0, 0, constMoveForce * Time.deltaTime);
}
this is where that function is being called
void FixedUpdate()
{
//Loop through rows
for (int i = 0; i < obstacleRows.GetLength(0); i++)
{
//Reset position of off-screen rows of obstacles
spawnBlocksOffscreen(obstacleRows, i);
//Move all obstacles towards player
for(int j = 0; j < obstacleRows.GetLength(1); j++)
{
moveSpawnedBlock(obstacleRows[i, j]);
}
}
}
and lastly, here is the function which spawns in the obstacles
void spawnBlocksStart()
{
//variable setup
int randIndex = 0; //index of hole
int instCount = 0; //number of obstacles made
//Loop through all spawn-points
for (int i = 0; i < spawnPoints.Length; i++)
{
//Create gap on each row
if (i % blocksPerRow == 0) randIndex = Random.Range(i, i + blocksPerRow);
if (randIndex == i) continue; //skip obj creation if reaches pos of gap
//Instantiate obstacle
obstacleInstances[instCount] = Instantiate(obstacle, spawnPoints[i].position, Quaternion.identity);
instCount++;
//Skip row formation if row is not complete
if (instCount % (blocksPerRow - 1) != 0) continue;
//Collect row
var rowCount = (instCount / (blocksPerRow - 1)) - 1;
for (int j = 0; j < (blocksPerRow - 1); j++)
{
var instID = instCount - ((blocksPerRow - 1) - j);
obstacleRows[rowCount, j] = obstacleInstances[instID];
//Debug.Log(obstacleRows[rowCount, j]);
}
}
}
any idea why this isnt working? im confused :') sorry if this is badly formatted, or if my issue is obvious. this is my first time working in unity and my first time using C#.
forgot to include the whole script, here it is