#๐ปโcode-beginner
1 messages ยท Page 628 of 1
Does it play once?
i can click once and it play and when i click it again it doesnt play anymore
but i dont want a loop
hello can someone please help?
did you check the console window ?
Where do I find the IDE set up for Unity?
this comes up
!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
ty
just because you are mad that i told you to learn the basics of c# does not mean you need to ping me justifying why you are asking a question every single time you do so.
@rich adder
are you sure the button presses /clicks is playing it at all? Cause you got Play On Awake you must be hearing that
i made an infinite loop on start, how can unity from executing?
You're going to have to kill the process in task manager.
unfortunate, would've been nice for a kill option

i mean, isn't that the kill option
Haha, why not create a program to kill the executable? ๐
*kill option that doesn't make me reopen the whole project ๐
yes because the sound i comeing one time
its infinite. The program doesnt know it needs to be killed since its stil " processing"
it will keep eating RAM until crash
@rich adder but if i click the button again after the one time it doesnt work
from the click or Play On Awake
But does it play when you click it or at the start of the scene
Follow up, is there any way to debug the infinite loop? considering it seems like i don't have access to the console while it's "processing"
show code
look at all the places you are using a while loop or infinite for loop, or recursive method
why are you putting the add listener there
has its consequences
also why is it in start
You could use a debugger and you can also check the log files if theres anything useful printed out
wait.. just think for a moment stop doing random things
too much sugar
Put the log where I told you to put it
inside PlaySound
if you attach your debugger to unity you can use the Break All button to pause execution while the loop is happening then check what is happening on the main thread to see what is causing your infinite loop
Debug breakpoint, or engineer an exit condition like counting loops and quitting early if it gets too high.
But it should be fairly clear what's infinite, look for while loops you added recently
guys can someone say now what the problem is that i can only play it once
if you refuse to debug , no one is gonna help
i told you how
@raw fiber
again, we need to see if PlaySound is being called at all
clicksound is probably null
What is supposed to play it
Put Debug.Log inside PlaySound function, to see how many times that method is being called
They said "i can click once and it play" but it's probably just the play on awake
at the start omg bro
? You said it plays when you click
And now you say a different thing
Like it's somehow obvious
...why
good job
instruction arent your thing
takes time
ok but how can i do it now?
you test if PlaySound is being called at all
put log inside of it before the if statement
idk its not that complicated of an instruction is it?
log? you mean debug.log?
thats what I been saying yes..
No, he means Yule Log, the christmas delicacy and/or the actual fireplace log that it's based off of (apparently it's not just a cake! I learned something today)
๐ชต
Debug.Log("Hello, this is being called", gameObject)
untick collapse in Console window
thanks everyone!
where do i need to put it inside the if statement or what?
do both.. put 2 logs in..
pay attention plz
dude at this point you gotta google
yes
you see what i mean
im so confused rn
im so sorry
no worries man we all started the same way
this is why you were instructed to learn the basics
Before if statements means it goes ABOVE
bro boxfriend
code runs from top to bottom
just please learn the basics
please just say it to me
ich kann es auch in Deutsch sagen
Debug.Log Mann
just give me the line of code empty but in right order and everything
einfach Debug.Log
we need Neon Signs too I'm thinking
bro wo รผber if oder bei if
english only server
If it gets this conversation over with, German is fine
exactly
bro where above oder at if
I gave you the exact line of code.. what more do you want
do you want me to hold your mouse for you too
in deinem If statement schreib Debug.Log("played")
what is supposed to come in side debug.log
this in english only server, keep it so
i get cs0104
it doesnt matter at this point in time what the hell is inside the message of the Log. the importance here is that it prints..
error codes are for computers
show what u wrote
after this go through the basics or you're gonna burn al your help cards here believe it
wtf
I know the problems solved already I just needed to find a comically large picture of an arrow
took me a bit
worth
what is the right debug class?
the one inside UnityEngine namespace
i only get a green one
you should remove the one that has Debug from System.Diagnostic
If you have using System in the top of your file (or anything inside of system) remove it
yes i have it
DELETE IT
It begins again
omg finaly no error
yes things go smooth if you pay attention to instructions
same thing
same thing what?
only playes once
is it printing in the console when you press button
i dot wanna script today anymore
and just for good measure send what you wrote
this is a mobile game button
The entire point of the debug log was as a tool for seeing what the code is doing. This is an information gathering step
nothing is showing up
Now you can see when the function is called
then the button isnt working
If you get no logs, then the function isn't running
only
Which is, itself, information
assuming you put the log before the if
if you dont see other logs then the button is not working
If you don't get the log you just put in, then you're never calling the function
typically, either something is covering it OR you dont have an event system
So it's not running at all
can you show your button inspector + code?
nothing running
show where you put the log
he probably didnt add a listener to the button
@raw fiber Please make a thread, you're spamming this channel with your noise at this point.
sorry
he has
what?
Oh my fucking god it's still not before the if
I don't have a higher resolution arrow image to point to the instructions again
oof
they are using a SpriteRenderer..
and no canvas
and no event system
this borked
can someone please give a tut
please basics
look one up
๐
LMAO
bro on youtube there are only tuts for movement on mobile
imbicile
@raw fiber If your next message isn't making a thread, you will be muted.
And if your persistence on not learning, and expecting people to solve all your issues continues, you will be muted.
@frosty hound buddy this was no question this was a thing
!mute 986696803208532078 1d You can return tomorrow.
snail_thunder was muted.
is this a place to ask for help?
Sure, if it's related to beginner coding concepts in Unity
Otherwise, #๐โfind-a-channel for one more relevant if it's not
idk if has to do with coding or not
but its like when i click play and go to my game menu and click on level 1, the enemies in the inspector and waves just all disappear
but then when i exit play mode they just all go back
Well, everything should go back to normal when you exit play mode, any changes to anything during play mode get reverted
no its not that
its like i put it there when im in exited play mode
but then when i play and click on level 1
they just all disappear
like i use the same script for level 2
and for some reason they are stilll there for level 2
but they just disappear in level 1
Well, first off, are you getting any errors in the console
lemme check
nope no errors
like it shows this in the inspector when im not playing
but then when i play it just becomes this
something is probably setting that list empty / creating a new one in code
no
if i like play the game from level 1
its there
but when i play the game from the game menu and click on level 1
it just disappears
they probably are two different instances?
yea but
i did the same for level 2
and i played level 2 from the game menu
its there
but its just not there for level 1?
something is telling it to do that, find out what has a reference to it
in the scripts?
yea
!code
๐ Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Use a paste site to post your !code . . .
๐ Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
delete this and post properly
can i just upload file?
Read the bot message we both posted. It tells you exactly what to do . . .
Yes; you paste the code, save it, and post the link for us . . .
you're supposed to SAVE IT then get the generated link
not send us the root of the website..
A tool for sharing your source code with the world!
i cant get my object to move, using a rigidbody and it wont work correctly. It has a rigidbody attached and im using rb.addforce and its not showing any actual errors but the object wont move.
show inspector , show console , show code
public Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
rb.AddForce(transform.forward * 20f);
}
okay, and the other things ?
is my problem fixed yet/
In the inspector, is the rb variable assigned?
yeah
only you know if it's still happening
still happening
There's no way for us to know if you fixed it or not . . .
so uhh what now?
Did you change any of the rigidbody settings?
why is the inspector different
record a video and show the issue happening. Make sure to include the hierarchy and inspector in the recording, do not crop anything out
does he think someone else is gonna fix it for him-
turned gravity off and set it to interpolate and continuous
but i also tried it w the default stuff just incase that was the issue
oh yeah i have some other variables in it that im not doing anything with rn
is the rigidody on the same object as this script?
mp4 for Discord embed
yep
Does the object have an animator?
how do i do an mp4?
dont think so
something you should've probably mentioned when they asked " if you changed anything on RB" lol
Either use something that records an mp4 or use https://handbrake.fr/ to convert
it was on network rigidbody so i didnt think to but in hindsight yeah
welp
learning curves
online converter or there is option in OBS
forgot where
ShareX is good too
lmao just turned kinematic off and saw it go past at mach speeds awesome that fixed it
thats because in Multiplayer uses kinematic bodies for clients to simulate the physics
ohhh
also probably not a good idea to do Multiplayer if you dont know the unity basics yet ๐
see i didnt realise that and was just looking at my player prefab and doing the same stuff w the logic of "this is how i do it"
probably ๐
yaa..its gonna get quite complex, quickly lol
start with a simpler thing, work your way up
noted, thanks ๐
Is something destroying the Levelmanager GameObject and instantiating it on scene load?
LevelManager is a prefab, are you creating a new instance maybe and deleting old one?
i did the same for level 2 and it works
jinx!
by "the same" wdym
irrelevant, something in this scene could still be doing it.. but not doing it in scene 2
i used the same scripts and setup
So.. it's a yes/ no question.. and if you're not sure, you need to check and confirm
we dont know for sure what is different because we havent seen the entire setup
A list won't become empty on its own, SOMETHING you've done/setup has to be interacting with the component or the game object
maybe?
so what would i need to double check?
like the script?
sure whatever handles LevelManager prefab
so like a picture?
No
Be mindful, if someone requests your code as text, don't send a screenshot!
whats Spawns LevelManager
also doesnt seem EnemySpawner is part of the original prefab
oh the levelmanager script?
we do not know if levelmanager class spawns itself.
yeah but if its creating it with a blank EnemySpawner, we dont know your setup lol you're the one that should know, you made it
nah
i followed an online tutorial
and just modified the game by myself a little bit
well whatever you touched broke it then ๐คทโโ๏ธ
if you dont know your own setup its going to be difficult fixing
so right now were looking for if the level 1 enemyspawner is loading?
you would check if something might be finding / Spawning LevelManager and deleting the old one for some reason
control + shift + F in VS and check for "LevelManager"
right?
Haha, I just saw that. If you want to use a kinematic rigidbody, you have to use the MovePosition method . . .
if we are talking singletons though I would assume that you have a spare level manager in Level 1 scene, but not in Level 2 scene @hidden fossil
Check which scenes have a level manager . . .
ok
i dont have a spare level manager anywhere
can you show us your LevelManager script?
!code
๐ Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
A tool for sharing your source code with the world!
ok just to double check, because you are using a static instance so its quite likely
type LevelManager in here in all scenes to make 100% sure you dont have another one
is there something that spawns LevelManager?
LevelManager is also missing the singleton cleanup so that might not be the one deleting the copy (if one existed)
yeah, the way he has it I think will overwrite the instance whenever there is a new one
anything else?
yeah when you access the Instance it will grab the new one
so is that the problem?
not 100% but likely
try this https://paste.mod.gg/fgyyaikcpuwv/0
A tool for sharing your source code with the world!
if you want to read up on what this is in more detail ill get you a resource real quick
https://gamedevbeginner.com/singletons-in-unity-the-right-way/, be careful though as singletons come with some major downsides, especially if overused so try not to rely on the pattern too much
Destroy(this); much better to just destroy the entire GameObject instead of the component Destroy(gameObject);
i was going to say "what if you have another script attached" but then again when would that ever happen with a singleton where you want two
so I think you're right
the code u sent me is giving thousands of bugs
ya there could be otherscripts on that object ( i know mine does)
that uses that singleton as SerializeField since its on same object anyway
could you show the errors? what bugs are happening?
oh wait
whoops
change Instance to main
oh yea thats the problem
you usually want to name it Instance though from what I understand, seems to be standard practice
but its really semantics
alright all fixed ima test it now
outta nowhere unity uses Singleton for NGO Network manager
is there actually a case where you wouldn't want to Destroy just the singleton though?
nope still not working
so what is not working exactly just to confirm
so like when i play level 1 from level 1 scene
No idea. I just destroy the entire object lol
it shows that the wave setting is all set and enemies are there
but when i play level 1 from the game menu
the wave setting and enemies just all disappear and spawns nothing
wait sorry typo, i meant where you wouldnt want to destroy the whole object
in practice i mean
like the inspector is even empty for the wave setting
since you prob wouldnt couple a singleton to a non-single instance class
but when i exit play mode and go to inspector it just all comes back
do you have a level manager in the menu scene?
no
no idea, but basically you're getting a very minimal amount of allocation back from cleanup since you don't have an extra thing loaded for no reason
i need a level manager in the menu scene?
such a tiny amount in the grand scheme its a non-issue
im not sure, can you show where you use the level manager
like other scripts where you do LevelManager.main...
if i have a object with a dependency on a component in a child object, should i get the component in Awake() or Start()
i dont see anything that would cause the issue here. so what happens is that you load into the scene, and the level manager's references are gone?
could you show the inspector for it both in edit mode and play mode?
from like the game menu scene play?
before i play level 1
and this is in the level 1 scene right?
after
are you sure this is the same one? i dont see build manager in the first screen shot
are you spawning a prefab? because from the looks of it you have made changes to the one in the scene but not saved those changes to the prefab
its below it
like everything else in levelmanager is there except for the wave settings when i play
i dont think he is... but i could be wrong? seems he has set LevelManagers in the scenes
oh were prob looking in the wrong place
show the EnemySpawner class
script or inspector?
script pls
!code
๐ Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
A tool for sharing your source code with the world!
wait i got an idea on how to fix this
since it works on level 2 but not on level 1
can i just duplicate level 2 scene and delete level 1 scene?
and change it?
should i try it?
ok
yea, i did made level 3 by duplicating level 2 and it works
but level 1 still doesnt owrk
so im guessing delete level 1?
Im having some issue with the IDragHandler interface. if anyone could help me out
I have included event systems, I'm inheriting all 3 of the interfaces IBeginDragHandler, IDragHandler, IEndDragHandler
but yet all 3 of these functions dont log anything, so therefor I assume are never called
public void OnBeginDrag(PointerEventData eventData)
{
Debug.Log("drag start");
velocity = 0f; // Stop momentum
}
public void OnDrag(PointerEventData eventData)
{
Debug.Log("draging");
SelectedIndex -= eventData.delta.x * dragSensitivity;
}
public void OnEndDrag(PointerEventData eventData)
{
Debug.Log("drag end");
velocity = -eventData.delta.x * dragSensitivity * 10f;
}
any rigid body used?
for some more context this is a script on an empty gameobject inside a panel. I got it to work for a second but then it stopped
is on drag for rigid bodys only?
no
if u used rigidbody i think u would have to write velocity to linearvelocity
i think btw im not sure
yeah the issue is im not even getting the debug.log
the other code im fairly certain works, but is just never triggering
does the object have a collider?
there's a couple channels that could be the most appropriate spot for this question so apologies but regarding like displaying 2d tiles, That's generally down from top left to bottom right correct?
yes
it didnt but adding one didnt change anything
feels weird doing it for the first time because in regards to setting position i gotta use positive x but negative y so it made me question reality aha
wait i might be miss remembering since my game is a digging game so I wanted it to go down. I think it is bottom left to top right
yeah its a standard cord system and you are starting at 0,0. the direction you chose to populate is up to you.
for example I populate my world like this:
Vector3Int[] vector3Ints = new Vector3Int[width * mapChunkSize];
for (int y = 0; y < mapChunkSize; y++)
for (int x = -width / 2; x < width / 2; x++)
vector3Ints[y*width+x + (width / 2)] = new Vector3Int(x, -y, 0);
world.ClearAllTiles();
world.SetTiles(vector3Ints, mapData.tileArr);
where world is a tileMap, and mapData.tileArr is just a 1d array of tiles
that makes 0,0 the top center and it populates downwards
how can I change the object reference of this specific binding via code?
its probably a struct in Playable Director
but with key does it mean the previous object or what
"The source object in the PlayableBinding"
mhhh
so what if its null?
I hoped to do something simple like this (code as screen so you can see the error)
System.RuntimeType.InvokeMember (System.String name, System.Reflection.BindingFlags bindingFlags, System.Reflection.Binder binder, System.Object target, System.Object[] providedArgs, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParams) (at <191a1970a53948f9819ac1d2e4f5c72e>:0)
UnityEngine.SetupCoroutine.InvokeMember (System.Object behaviour, System.String name, System.Object variable) (at <84f0d810adef4e6c8deab33e4ae93f7c>:0)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)
what does this error message mean?
Something's trying to call MeleeAttack.OnMelee but it doesn't exist
Since it's an Invoke or a Coroutine with a string parameter, there is no stacktrace
Well, no useful stack trace
One of the main reasons not to use those
For key?
You hooked up your OnMelee in PlayerInput or some other part of the Input System incorrectly
okay so rn im using a triangle as a temporary trigger to deal damage but its very incosistent anyways to make it better?
but it works when i move the hitbox around more
how do i make a day/night cycle for my game?
Search up online, this topic has been asked to death
Hello
So uh...
I have Heard is recommended to check some courses online to learn some programming
But how can i know if a course is good or not before buying it?
Read reviews? ๐
Don't pay for online courses. All that info is likely available for free
But in this day, you don't need to buy courses. Everything you need to learn is free.
Mostly asking because i would like to have a base to start with
I know everything is available in the internet but there is so much that idk what to do or try first
You're overthinking it. There are pinned resources in this channel you can start with.
Okay i can check that out
Also i see the page is mainly in English but are these explanations also available in any other language?
No idea
idk why but i gotta move my cursor to register the hit and idk why that is
register what hit? Context?
well the melee hit i got my hitbox and the first hit registers but if i keep it at the same position it doesnt register the second damage hit
You would have to explain how you're doing things right now
and show your code
using UnityEngine.InputSystem;
using System.Collections.Generic;
public class PlayerCombat : MonoBehaviour
{
public GameObject Melee;
public float atkDuration = 0.5f;
public float damage = 10f;
private bool isAttacking = false;
private float atkTimer = 0f;
private InputAction meleeAction;
private HashSet<Collider2D> hitEnemies = new HashSet<Collider2D>();
private void Awake()
{
meleeAction = GetComponent<PlayerInput>().actions["Melee"];
if (Melee == null) Debug.LogError("โ ๏ธ Melee GameObject is not assigned!");
Melee.SetActive(false);
}
private void OnEnable() => meleeAction.performed += _ => StartAttack();
private void OnDisable() => meleeAction.performed -= _ => StartAttack();
private void Update()
{
if (isAttacking) HandleAttack();
}
private void StartAttack()
{
if (!isAttacking)
{
Melee.SetActive(true);
isAttacking = true;
atkTimer = 0f;
hitEnemies.Clear();
}
}
private void HandleAttack()
{
atkTimer += Time.deltaTime;
if (atkTimer >= atkDuration)
{
isAttacking = false;
Melee.SetActive(false);
}
}
private void OnTriggerEnter2D(Collider2D other)
{
if (isAttacking && other.CompareTag("Enemy") && !hitEnemies.Contains(other))
{
Enemy enemy = other.GetComponent<Enemy>();
if (enemy != null)
{
enemy.TakeDamage(damage);
hitEnemies.Add(other);
}
}
}
}
thats the hitdetection and attack code
activating a collider for an attack is super awkward
just use a direct physics query
and how do i do that im like very new to this
e..g Physics2D.OverlapXXX or Physics2D.XXXCast
only on the player or also on the enemy?
whover is attacking would use a physics query to detect hostile characters to hit.
ill look into it tomorrow too tired rn
I'm attempting to transform a mesh which is in the shape of a toothbrush but I think it still has the original mesh of the square I placed the sprite onto, because when I get the length and width of the sprite, they are equal. How can I fix this?
Why does my input map keep getting lost? Kind of a minor thing because I just need to re-apply it, but for some reason, th Input map here just keeps going "missing" and I have to re-add it
is your code destroying it?
No, all my code is doing is referencing the messages it sends
it still has the original mesh of the square
Huh? What square? What are we talking about?
I placed the sprite onto
Are we talking about meshes or sprites here?
Can you share more context?
missing means it was destroyed
What did you assign it to?
these are the only two scripts making any use of input, when I re-add it and play the game, everything is fine, it seems like if I keep the editor open for a while (like working on something else) it for some reason removes it?
Well when I made the PNG I imported it into my Sprites folder. I made a square in the workspace and then put the sprite onto the little black bar in the inspector (sorry I'm new to unity I don't know the words for some things), so I have the toothbrush PNG in the game. I want to be able to click on the screen and the toothbrush moves to where I clicked, I got it working but it always landed in the middle of the toothbrush which isn't what I wanted, so I said okay all I have to do is get the length of the toothbrush, halve it, turn it into a vector, and take it away from my mouse position. This is not working. The length of the toothbrush seems to not correct and when I tried to incorporate a width, it is the same as the length
but what did you assign it to
I can post my code here if you want
what do you mena?
I made a square in the workspace and then put the sprite onto the little black bar in the inspector
What's a workspace? What black bar in the inspector? The inspector of what?
I got it working but it always landed in the middle of the toothbrush which isn't what I wanted, so I said okay all I have to do is get the length of the toothbrush, halve it, turn it into a vector, and take it away from my mouse position. This is not working. The length of the toothbrush seems to not correct and when I tried to incorporate a width, it is the same as the length
Sounds like you actually want to just change the pivot of the sprite, which you can do from the sprite editor. Access the sprite editor by selecting your image file and selcting sprite editor at the top
This field
which actions asset did you assign it to?
Oh, I hjave a custom mapping I made
And where is that? is it in any special folder or anything
Just in an Input folder under the generic Assets folder Unity starts with
I wonder if maybe I just accidentally assigned it to the player in the map instead of the player prefab, who knows, if it happens again I will come back and worry about it...
I'm a blender veteran that's why I'm getting confused over meshes and stuff I don't get how unity does things
I could technically divide them by 4 and it would look alright but it's for my coursework I have to explain my code as I go along and I can't really say "it looked okay"
You didn't show the part of the code that actually positions the object so it's not clear how that works
but I don't understand why you're doing all this bounds stuff
Because I want the object to go to the mouse when I click but I don't want it to be centered at the mouse
Ok so like I said above:
Sounds like you actually want to just change the pivot of the sprite, which you can do from the sprite editor. Access the sprite editor by selecting your image file and selecting sprite editor at the top
I want it to be offset by its length
changing the pivot would be the easiest way
Idk what that means
I gave specific instructions on how to change the pivot.
The pivot is where the actual position of the object is
such that when you do transform.position = somePosition the pivot of the sprite will go exactly to somePosition
Also please when sharing code here please don't use screenshots. !code
๐ Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Apologies
I'm tryna find it rn
The sprite is definitely not "still a square"
the bounds of the SpriteRenderer will be based on the sprite import settings
specifically the boundaries of the sprite as represented in the sprite editor, and whether your mesh mode is set to Tight or Full Rect
should be a button in the inspector
like this
(although that's a pretty outdated screenshot it should be similar)
Oh yes I see it
Okay Pivot is on centre right now so I change it to wherever I want my mouse to land?
Where I want it to land when I click my mouse*
Okay thank you brother
also remember to take out the bounds calculation offset stuff from the code
Of course ๐
I'm in Unity, what's the best way to reinstaniate a UI slider after a scene reload? I have a Manager object that I drag the sliders onto for my script's public variables and they work on the first play. But If I trigger a Scene reload, the sliders won't reinstantiate for my Manager object's script. I have this in the Awake() method of my Manager's script: healthSlider = GameObject.FindWithTag("HealthSlider")?.GetComponent<Slider>();
Can I not do this with UI elements like I would a regular gameObject?
What makes you say that? That code is working perfectly fine
your problem is that Awake only runs once per object
So it's not going to run again when you load a new scene
basically it's odd for this "manager" to have references to other objects in the scene when it's apparently a DDOL object
and those other things are not
that's a design that isn't going to work
Some options are:
- Make the manager not DDOL.
- Make the UI stuff also DDOL
- Make the UI elements register themselves with the manager when they are created (in their OnEnable)
- Switch the dependency - make the UI elements listen to an event to update themselves instead of the manager referencing them and updating them
Is this how VS Code Community looks?
That's Visual Studio not VSCode
I was gonna use VSCode but one of my friends told me not to because apparently it doesn't autofill
I just use extensions
Make the UI stuff also DDOL
This sounds like it's the easiest, but which do you like best?
That doesn't sound the easiest to me at all.
I would personally do one of the last two suggestions most likely
but I don't know the specific details here
so it's hard to say
the first is also a strong contender
The first is definitely the easiest, but it depends on what else this "manager" does and why it needs to be DDOL in the first place
I suspect I made too many managers. I started off with just 1 scene "Gameplay". I made a StatsManager as a singleton instance to handle player's current and max health, magic (sliders). Then I made a "Title" scene and a GameManager to handle when Game Over is reached and scene transfers. I thought maybe the GameManager should take over all managerial responsibilities. Thoughts?
The only reason to DDOL any managers was initially to reset the current values of the health and magic sliders. Then GameManager seemed like it also needed DDOL to handle scene transfers
For game state data I generally have one manager that holds all of the game state.
As for the UI it should definitely be observing the game data, not the other way around
the observer pattern is something to look into
who is the broadcaster of the event the UI should be subscribing to?
whatever manages the data that's changing
i.e.:
something happens in the game (player gets hit?) -> the new player HP is set on the data manager. -> Data manager fires an event -> The UI receives the event broadcast and updates itself
why does my velocity.magnitude go this low?
that's basically 0
this is when the player is litreally isnt moving
can i floor it?
if you want
whats the thing for that again haha
if (rb.velocity.magnitude < someThreshold) rb.velocity = Vector3.zero;
Thanks for the advice! I'll try refactoring my code some more with this in mind
not really necessary to floor it, that is literally 0.0000002 meters per second so after a few minutes it may have moved a barely noticable amount
dont worry i gott it i just needed to look at it like it was floored so i can fuck about with it easier
bless you all
its cause the way i was doing code would take a second to deactivate cause it wasnt technically 0 so ill just floor it
easy peasy
ah, sounds like you may have been doing float equality when you should pretty much never do that. there's the Mathf.Approximately method to handle comparing floats, it checks if the difference between them is less than Mathf.Epsilon
hey I realized a really noob mistake I made in a script a long time ago and its giving me a headache now
if (velocity.y < 0)
I'm using this as a check to see if my player is moving in the downward direction, but its inconsisten because... floating point values
I.E. the float is sometimes 0... and sometimes 0.0000000000003
whats a better, consistent way to check this?
tbf neither of those numbers is less than 0
if you want to know if your object is actually moving downward then you need to check if its velocity is below a lower threshold, because just because it is less than 0 does not mean it is low enough to actually be moving
er, yea, you're right that was a poor example
well the problem more specifically, is this
float directionY = Mathf.Sign(velocity.y);
this is returning -1 and 1 alternating rapidly, because when velocity.y should be 0, it sometimes is very slightly negative instead, so it makes directionY -1 when it should be 1
right so read my previous message
so something like this?
float directionY = velocity.y < -0.0001f? -1:1;
I am writing a shader to create a texture. I have seen people make the camera output the texture on the screen. So the screen renders the texture in its resolution. Does anyone know how to do this?
I think by putting a render texture as the cameras Output Texture but it just says "Display 1 No cameras rendering" so hm
You need a camera to render to the screen as well.
I don't know if a screen space canvas counts or not. Probably not.
So you'll need 2 cameras
Ah nvm. I did it wrong. But Graphics.Blit() does not work in URP anyways
guys i just have like a quick question about visual code studios
how do you implement that IDE where like for example if you type in the keyword f it gives you the option float and a bunch of other options?
!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
why? did you bother following the actual instructions for configuring vs code? or did you just go and search "IDE" in the extensions?
i went on one and it said u could just install one from the visual studio
huh?
oh wait nvm i forgot enable it in the unity
maybe take more than 2 seconds to actually read the page..
you arent even using visual studio
where did any instructions tell you to download the platformio extension?
An ide is an integrated development environment. Visual studio is an ide. visual studio code is sort of an ide(not really, but can be equivalent). You don't "install ide in an ide". That doesn't make sense
ok i should prob uninstall jetbrain rider
Rider is also an ide.
yea i put that as my preference but for some reason its n ot opening any scripts
and im trying to open the app but its not opening
guess it prob has a malware
yea idk why i put it as my external tools and its not opening any scripts the app isnt even opening when i double click onit
I've never used rider, so can't say for sure, but if it doesn't open, when you launch it via the exe, then it probably didn't install correctly
it said finish installing
but now it doesnt work?
its 1.4 gigabytes and the app says 1.4 gigabytes
ok im uninstalling it it is taking up too much storage and its not working
Why would you even go for Rider if you're a beginner?
!code
๐ Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
void FixedUpdate()
{
playerInput = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
rb.velocity = playerInput.normalized * moveSpeed;
if (Input.GetAxisRaw("Horizontal") < 0)
{
rb.transform.localScale = new Vector3(1, 1, 1);
}
else if (Input.GetAxisRaw("Horizontal") > 0)
{
rb.transform.localScale = new Vector3(-1, 1, 1);
}
if(Input.GetAxisRaw("Horizontal", "Vertical") > 0)
{
dust.Play();
}
else if()
{
dust.Pause();
}
}
}
how do i make it to where if my player is not moving, my dust particles dont show up, and when he is moving, they do show up?? i'll post more reference rn
did you read the error? GetAxisRaw doesn't take 2 strings. you also have a vector already that contains both horizontal and vertical input
i did but i didn't know what it meant
and your other else if() isnt valid c#, i recommend going over c# basics really so you arent struggling with both c# and unity at the same time
and i looked at the documentation and it still didnt make sense to me
the errors are just standard c#. there are pins in the channel for intro to c#
for your immediate problem, you could probably just compare the vector to Vector2.zero. if its the zero vector, pause the dust. else play the dust
you dont need to read the Input.GetAxisRaw("Horizontal") everytime as well. its already stored in playerInput
Vector2.zero would just mean that the player is not moving left or right, yeah??
i solved that part ty
Vector2.zero is just (0, 0). you'd be comparing the input to (0, 0)
oh yeah i remember now
theres nothing specific to if its actually moving or not, since it could be moving against a wall
Is this statement ok, or I am doing some forbidden math stuff? lol
https://learn.microsoft.com/en-us/dotnet/api/system.int32.minvalue?view=net-9.0
don't really know what you're trying to do with that but there is a min and max value const already
I want to do a loop on a list to get the lowest value on it, so the default min is... infinite
But health works on int, Math.Infinite is float
there is a min and max value const
you don't need to do anything float related if you want an int
int.MaxValue
So what's the difference?
the difference is you want an int. so just grab the int instead of doing it through a float
I'm having an issue. When loading a scene, I'm trying to move the player to a specific point, but there is something in the project that moves the player back to where it was before. I've been scouring all relevant scripts but am unable to find what causes it. Does anyone know anything that might help me locate the problem?
Start from listing the components/scripts that are relevant to the player movement
Bet that the character controller is responsible for that
I'm using this to play sound effects (sword slash for example), but (obviously) it keep creating new gameobjects that are never removed, what's the proper way to handle this?
audioSource.PlayOneShot(audioClip);```
Do I just have a GO in my scene to which I always add AudioSource components? Then destroy/remove the component when the sound is done?
Or do I just delete the GO every time?
Or should I be creating this GO & component just once and then only call PlayOneShot when a sound needs to be played?
Just reuse the same GameObject with an AudioSource; no need to keep creating a new one to add the component . . .
I used to have a soundmanager that spawns audisources, if needed and removes them when done. But only, if a certain amount of clips playing at the same time was hit. So imagine one source for weapons for example. And you play from there, but if its playing and you want to add another sound, spawn one temporary audiosource. Depends on your setup. If you know, you got two weapon sounds always, then keep 2 audiosource components alive and add a third for rare cases that gets removed or pooled
Yeah seems to work just fine, even with multiple sounds at the same time.
The tutorial I followed for this must have been really bad ๐
So bad that it should be removed from the internet
Let's learn how to play Sounds and create a simple Sound Manager class to handle playing any Sound we want in 2D and 3D.
GameAssets class video
https://www.youtube.com/watch?v=7GcEW6uwO8E
If you have any questions post them in the comments and I'll do my best to answer them.
See you next time!
Grab the game bundle at https://unitycodemonkey...
6 years old though
and maybe he goes on to fix the issues, didn't watch the rest lol
Why would you share it tho ๐ if its bad ๐
Jesus I did not expect code monkey to produce such garbage
I just scrubbed through, looks like he is fixing it at some point later
I recommend this guy I have yet to see a bad tut from him https://youtu.be/BgpqoRFCNOs?si=9fhybHVMyd1W7pee
Take control of the sounds in your game by pooling your Audio Sources! Reduce the number of real voices required to play a multitude of audio clips, manage their lifecycle, and enhance performance. Learn how to streamline your audio management and make your game sound fantastic with efficient audio source pooling!
Check the repository for impro...
Nah he does not ๐ keeps on creating gameobjects for every sound
cool, I'll check him out sometime
This is right up there with multiplying mouse pos with deltaTime
The amount of garbage tutorials out there is staggering
PlayOneShot is great for quick, short sounds. It plays the audio clip even if another sound is currently playing. You'll only have issues (sound cut off) if you repeatedly call it over and over . . .
If I ever need more complex sounds I have the video Uri linked ๐
for now this works fine
Imagine, youtube tutorial creators do a quality review with other devs before posting ๐ฑ ๐
gm guys. I know nothing about coding or developing a mobile game but I want to learn. can anyone suggest me a guide? I just want to be able to create mobile games?
!learn and go through the pathways there. There also might be some specific for mobile, but first of all, you gotta learn how to develop in general and use Unity in that case
:teacher: Unity Learn โ
Over 750 hours of free live and on-demand learning content for all levels of experience!
๐ด Get bonus content by supporting Game Makerโs Toolkit - https://gamemakerstoolkit.com/support/ ๐ด
Unity is an amazingly powerful game engine - but it can be hard to learn. Especially if you find tutorials hard to follow and prefer to learn by doing. If that sounds like you then this tutorial will get you acquainted with the basics - and then gi...
Be aware, its 2 years old and things can change.
It explains more how to learn instead of going in depth on unity
It was more of a general advice than specific to the content of that video ๐ If you hop on an older video or documentation and dont know how to handle deprecated stuff, you can easily get frustrated, so watchout for the timestamp on tutorials ๐
Doesn't help that Unity provides this evil built in function
public static void PlayClipAtPoint(AudioClip clip, Vector3 position, [UnityEngine.Internal.DefaultValue("1.0F")] float volume)
{
GameObject gameObject = new GameObject("One shot audio");
gameObject.transform.position = position;
AudioSource audioSource = (AudioSource)gameObject.AddComponent(typeof(AudioSource));
audioSource.clip = clip;
audioSource.spatialBlend = 1f;
audioSource.volume = volume;
audioSource.Play();
Object.Destroy(gameObject, clip.length * ((Time.timeScale < 0.01f) ? 0.01f : Time.timeScale));
}
That actually makes sense, because you want to play it at a specific spatial point, so you need to have a transform to drive your spatialblending, I guess
yeah but the creating and destruction for a single clip is awful
If you have some spare frame time budget, why not
you cant handle it another way than having a gameobject at that point wher eyou want your sound to happen. Of course would make sense to be able to pass in a already existing gameobject too, but if not, that method makes sense
I mean yeah you should have a gameobject and audio source where you wanna play it
i guess but seems like abit of a trap to be offered offically
thanks mate
True.
Though to be honest they mention it in the docs, so it's a trap for people that don't read docs.๐
i just looking more into scriptable object, is singleton outdated by this now ?
To be fair also, they have a lot of functions that we all generally advise not to use. Like the .find ones
They cant really code it another way
A singleton and a scriptable object solve entirely different problems
SOs are actual asset files that can live outside of runtime scope
I don't know which channel is most appropriate for this question, but I'm wondering why the size of my webGL build is so large, even after compressing most of the user assets (textures, sounds, etc)
this is an uncompressed build, but even the brotli build is 16 mb. Many people online have gotten their game down to 5mb or less
Also a singleton is a design pattern related to C# in general, whereas a SO is just a thing Unity created. It's not really possible for unity to make something in C# become obsolete
The rest is probably the engine binary. Might be able to reduce it by disabling some engine features and removing packages.๐ค
But 16 mb is pretty low tbh.
Oh, I see
I have this weird bug, i have like a particle.Play() in my script. But it only plays when i click something in the hierarchy it dosent mae sense, does anyone know a fix?
Add logs/breakpoints to confirm your assumption.
A singleton just gives you a static reference to an class instance, making it convenient to access a game object from anywhere. Good use case might be for a player character if you want an enemy script to reference the player.
SO is like a configuration, so if 5 classes share the same SO, they'll all be reading the same values
i have a debug.log in the part where the particle.play() is
its running
somehow only when i click on the hierarchy then it starts playing. Like i have to interact first then the particle really plays
We all love singletons but clearly not as much as you
I have love hate for them
Lmao
They're very helpful and I use them often
Can you write full messages?
I don't understand if the logs do print all the time, but the particles don't play, or the logs don't print either.
The debuglog is in the same if statement as the particle.play. But somehow only my log runs.
BUT when i interact with the hierarchy, my particle then stats playing (displaying)
Maybe your particle isn't play on awake? I vaguely remember that being a tickbox
Haven't used the particle system in a while
It's just that in some cases when needing a class to be static from the start, there's no need to make it a singleton, making it public static class Foo {} is all that's needed
Especially for classes that don't need to be MonoBehavior
I'm addicted to polymorphism and static classes just don't provide that
its play on awake too
Does that happen during play mode?
mhmm, it's all down to a case by case situation
I'm not being rude don't get me wrong this is incredibly informative but are you explaining this to anyone in particular lol?
Yeh
its a playmode problem, sorry i didnt clarify
I was saying my negative view to them, as you said I dislike singletons
this problem dosent make sense to me
I have just woken up so apologies ๐
That really is quite bizarre
Do you have the game view window/tab open?
And active
yes my scene and game is side by side
Hmm... Sounds like a bug. Hard to say anything without seeing your setup.
i also think its a bug.
ill try find another way around it
thank you for your help
Might want to fill a bug report and/or post on the forums.
i cant send you the gameplay too because its for a company
alrigt
thank you man
Have a look here on some more techniques to get your game to just a few MB: https://www.reddit.com/r/Unity3D/comments/icq2yw/how_to_optimize_unity_webgl_builds_from_230mb_to/
:teacher: Unity Learn โ
Over 750 hours of free live and on-demand learning content for all levels of experience!
Guys need help fixing this bug
Seems like your code is continually moving it into the ground
nope not into the ground i'm moving it towards the player
but somehow it keeps bugging
How are you moving it
I'll show you the code
Is your player an empty gameobject which has all the other stuff as its children? (Playermodel...)
heya guys, im a bit lost. hoping somone can help me without being too much of a nag
trying my hand at unity again after a many year hiadus (for context im a developer in mainly powershell and python so not a beginner there)
basically a complete beginner here but trying to 'just do some stuff' approach with some road blocks.
im trying to setup a third person aim camera for a basic scene at the moment, seen cinemachine used so trying to implement that but im struggling with probably a simply step.
i cant figure out how to setup a script for attaching camera movement and player movement to the player, the guides ive found are using depreciated cinemachine and aren't helpful.
Basically i want to create a variable to see x/y of mouse and transpose that onto player and camera rotation. Not sure if theres a doco or something i could be looking into as a few solutions iv'e found don't seem to work
https://assetstore.unity.com/packages/essentials/starter-assets-character-controllers-urp-267961
You can check out Unity's own sample for a character controller outfitted with a camera as well.
Cinemachine went through a bit of an overhaul with 3.0, so old tutorials will be slightly outdated when it comes to getting/modify properties on a virtual camera. The update was to make it easier to get those values by using the standard GetComponent to access them.
I have a problem with my game, i used the tutorial for the pause Menu (https://www.youtube.com/watch?v=qjgZTVEUqgo) and when I press esc it works fine, but the buttons dont work, I think some day I made some kind of a pause menu but i dont know where can someone help me find it and eliminate it?
I guess most of the people will watch the tutorial, so you should show your code and tell what "buttons dont work" means. Do you log anything to know, whast going on? How do you pause the game? etc etc
So all buttons dont work, i resume the game if i press escape again but i dont want that, the console doesnt say anything
except some other warnings which doesnt have anything to do with the menu
search for functions that would be related to a pause menu in the IDE... Pause().. UnPause() or w/e
then u'll know the script MyPauseMenu.cs or w/e then u can search in the Hiearchy to find what gameobject that is attached to..
thanks
sounds like it may be pausing by setting timescale to 0.. then ur updates will freeze and u wont be able to detect any other kind of input
oh ok i search for that now
if u followed along with the script ur logic should be pretty similar to theirs i guess ^
so whas the issue. u want the buttons to work while paused?
find ur EventSytem in ur project
aye.. soo ur using the oldschool input system? not the new one
there is a new one
im reading..
oh ok
its one of those threads where its like:
well, it could be this..
or it could be this..
or perhaps its this..
hm okey
I use this script for movement i think its somewhere in there the issue but there is nothing with escape or game pause or similar things
could very well be causing issue w/ cursor
say ur controller locks the cursor (hides it or w/e)
and ur pause menu tries to also change it.
could be conflicting
oh i think it hides it maybe let me look it up
๐
i just recently moved all my cursor logic into its own script
so both my controlller and my menu systems ask it to change it
instead of changing it itself
okey
ya, mine was like that too.. once i wanted to "make the cursor visible" with the pause menu
they'd try to fight each other
and the fps movement script wins i assume?
it might be that ur cursor is still locked to the center
when u hit esc.. the mouse breaks out of the window.. (but this isnt the same as being focused)
if u click back into the window and u hadn't unlocked it.. it snaps right back to the center
it isnt i can move it around until i press lmb
(if its centered it makes it hard to click anything else)
public class healingitem : MonoBehaviour
{
public GameObject detonate;
private void Update()
{
Debug.Log("just work you fucking moron");
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag.Equals("player"))
{
Destroy(detonate);
}
}
}
my object doesn't disappear when it collides with the player
oh
i forgot the debug message
i press escape then i can move the cursor around without an issue
before I made the pause menu with the tutorial i could press escape and the game paused and the cursor was visable forgot to say that
yes but thats only because ur unfocusing the window
wdym?
ur moving around the editor at that point.. not around the game view..
oh ok
unless u Unlock it.. via code.. when u click back into the game window it'll get Locked again
heres an example
oh ok i understand
i think ur character or something else is grabbing it and locking it
not giving it a chance to be able to navigate around ur buttons
u see all my Debugs in the corner?
thats how i helped build out my system..
its nice to know what ur mousePosition actually is..
doesnt work
u can debug.log it in an update() or something... when ur cursor gets grabbed and locked it'll spit out 0,0
oh ok
well thats not how u do it anyway lol
how?
still doesnt work
is there a difference when i let unity build the project?
and then try
if (Input.GetKeyDown(KeyCode.Escape)) // When Escape is pressed
{
if (Cursor.lockState == CursorLockMode.Locked)
{
// Unlock the cursor and make it visible
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
else
{
// Lock the cursor and hide it
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
}```
would: when u press esc... if the cursor lockstate is locked we unlock it
if the cursor lockstate isn't locked we lock it
do I put it in the fps movement script or the pause menu script?
that sounds logical
but probably need to keep it simple.. if u put it in ur controller..
dont accidently add something else to the main menu..
this is fps movement
and vice versa.. the best thing imo is to have a gamemanager controllnig this type of thing
that way when anything wants to lock or unlock it has to go thru the game manager
that way it isnt taking over control itself. and maybe breaking other things
ur IDE doesn't seem to be configured either.. btw..
!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
this should have errored out
okey so the fps movement?
Hello, I think I am missing something fundamental here but:
I have created a test folder in unity that lives at Assets/Scripts/Tests and have a bunch of public classes I want to access defined in Assets/Scripts. I'm having trouble getting my test script to reference those classes as they are not defined in the context while I'm running my script. Can someone help explain to me what is going on with the scope and context here when I run tests through Unity TestRunner?
hold up, i broke my own system trying to figure out urs lol
doesnt work
can u !code share ur movement script and ur pause script..
๐ Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
you're not gonna sort it out by changing one thng w/o changing the other thing
they'll need to work together
!code share
๐ Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
or both of em use some other script to toggle and manage the cursor as i said earlier
!code share
๐ Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
use a paste-bin service.. (all those links under the largecode block section of the bot message)
oh ok
thats y it keeps responding to u
just paste in ur script.. hit the save button and it'll generate a new url u can copy and paste here.
keeeps the channel clean
aight give me a second i have an idea that might work.. (using a Manager type script that both the pause menu and the controller can reference)
when they need to unlock or lock the cursor they tell it to do it instead..
okey sounds good
โ break tho
too much head flexing
brain starting to hurt already cant remember which project i just fkcd up
ill start a thread and ping u when i return cool/
yeapo sure
aight im back
and.. mines still broken for some reason mines getting instantly locked and hidden ๐
and i can't find it in my own code..
-# standby
Destroy(gameObject); is not working, but its rotating fine
That code is probably just not running at all
Which means you didn't set up the scene properly for OnTriggerEnter
what does that mean
It means certain conditions need to exist in the scene for that to run, and those conditions are not present
im doing the beginner tutorial and ive re read all the steps to check if i missed anyhting
You must have missed something
Feel free to show how your objects are set up if you want a second set of eyes
inb4 is trigger is false
Neither of your colliders is a trigger
Check the box to... Yeah
appreciate it
did you find a solution
yea hangon.. im making a package out of it
its easier to just show u the entire example and let u work out the issues in ur own system
ok
can we maybe go in a call later so its easier to communicate
if it still doesnt work
I actually saw that video before posting my question
But it's strangeโI created an empty Unity 6 project with URP and made a WebGL build with default settings (Brotli compression), and it's 10.7 mb. How on earth did people get their builds under 5 mb? Even the reddit video promises under 5 mb
u should be able to figure it out.. if not u can ask here.. shouldn't be anything that needs a call..
plus im at work right now ๐
check that package out.. ^ should have everything set-up for you to look around and see how its all working together... key point is:
- anything that wants to mess w/ the cursors (hide it, unlock it, lock it, etc) is done by calling the
MasterMousesingleton...
that way theres only 1 script in charge of it.. you don't want multiple scripts fighting telling it to do something, let's say there's one script trying to lock it.. but then theres another script (that maybe you don't know about) thats going right behind it trying to unlock it... it gets really confusing really quickly if u have it happening in multiple places
and please note.. that i didn't mess with the time in my example.. its just dealing w/ the cursor..
i had to create a new scene.. b/c i did break my old scene (still trying to fix it)..
its b/c i have that same issue as well.. i got multiple things all trying to control the cursor ๐ญ
can't remember exactly where tho lol
URP is larger out of the box https://github.com/JohannesDeml/UnityWebGL-LoadingTest. Empty projects also aren't necessarily minimal.
Are you aiming for instant game platforms or do you have some other pressure to get super small build sizes?
Let's move this to #๐โweb
and something else you may want to know is use the EventSystem component to your advantage
if you expand it in the inspector in Playmode.. it'll give you lots of information...
in this example you can see.. (when i click into the game and its "unpaused" the numbers don't change) thats b/c its locked.. when i press the Tab key.. or w/e is set up to pause and unpause you can notice that all of a sudden the values start changing quickly.. (thats when we're not locked) and the cursor is actively moving around the UI/scene
and Debug.Log()s if ur not using those while ur learning, then ur doing it wrong ๐
you want to give urself as much information as possible when learning... and you need to get ur IDE configured correctly b4 someone else calls you out on it.. alot of people wont even help you until you do..
you snitched on yourself here: #๐ปโcode-beginner message b/c that code should be underlined in red since its not correct..
also added my own in the MasterMouse script that you can spectate there as well.. you can see it acts the same
and the last tip i can give you b4 i gotta get back to work..
Consider using an alternative key that you don't use very often to test your pause system.. example, I chose 'Tab' in my test scene that I sent you.```
Show a video of the issue and also your joint settings
void Start()
{
head_up = false;
jump_trigger = false;
use_trigger = false;
jump_has_ended = true;
head_2_target_lerp_val = 0F;
head_2_target_lerp_min = 0.15F;
head_2_target_lerp_max = 0.65F;
// from here
Cursor.lockState = CursorLockMode.Locked; //Mauszeiger im Fenster einsperren
Cursor.visible = false; //Mauszeiger unsichtbar
if (Input.GetKeyDown(KeyCode.Escape)) // When Escape is pressed
{
if (Cursor.lockState == CursorLockMode.Locked)
{
// Unlock the cursor and make it visible
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
else
{
// Lock the cursor and hide it
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
// to here
}``` @steady flame and this is odd.. in ur character controller..
you have this logic in the Start() method.. Start() only runs for 1 frame.... theres no way that it's gonna detect ur Input there anyway... But this logic can be removed from teh character controller anyway..
you can instead have a reference to ur controller in the PauseSystem script.. and when it gets paused you can set a bool in the controller called `canMove` or something
like `characterController.canMove = false;` while its paused and
`.canMove = true;` once u unpause.. and then the character controller can just do its movement if the bool is true..
if the legs are whats causing the issue.. start w/ that
if its not enough you'll be asked to provide more ๐
best of luck Finn, eugen.. ๐ work calls ๐
lots of active ragdoll projects around lately
You probably want to adjust the axis of the leg joints
The setup looks weird though
Why is everything free
Is that a leg joint?
hey guys....so im thinking of making an npc which is ai based....meaning it learns from its actions by using machine learning and ai algorithms...i cant think of a way to start making it....can someone help me??
it wasnt supposed to?
Well normally you'd at least lock the positions instead of just using limits for the position
Did you follow a tutorial?
I knew it was AI code, didn't want to assume just yet
That's not the main issue
oh mb
The joint axis direction is
Adjust the Axis so that it rotates around the correct axis
Currently it is 1, 0, 0, which seems to be wrong
thanks a lot!
can someone explain to me in very simple terms what instantiating is? i looked around and i didnt understand any of the explanations