#๐ปโcode-beginner
1 messages ยท Page 267 of 1
Either that or if you're aware of the two objects and only need these two objects to ignore each other, you can opt for https://docs.unity3d.com/ScriptReference/Physics.IgnoreCollision.html
Check if it is the character or camera stuttering. Easiest way is to watch it in scene view, if the character moves smoothly then it is the camera
yes thx its the camera the player is moving smooth
what did you do
this is unrelated to the error
at some point you assigned incorrect value to gameObject.layer
I dont know where really because the original layer is assigned in Start
I have a working score in my ingame quiz scene, which is ++ if correct answer, but i want to make it appear in the next scene, printing that player 1 has had ... right answers.
How do i do that? its smh not saving the score for the next scene
show
Well you can it make it DontDestroyOnLoad
then InvulnerableLayer has incorrect value
how do i write that
what does "incorrect value" mean?
error says 0.. 31
yeah
gameObject.layer is not layermask
oh
DontDestroyOnLoad(theObjectYouWant)
https://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html
just int value directly
one is bit flags another is just an int
so I should introduce the layer number?
There is also PlayerPrefs you could use but that also saves between sessions, so if you want fresh score each run you'd have to wipe value
8 in this case
there probably is a method in LayerMask struct that converts layer name to its int value, or something else
and I specified not to collide here
my game is like 3 questions for player 1 -> scene which shows his results and for player 2 to get ready -> 3 questions for player 2 -> End Scene and who won (game for one handy, not online)
is this 2D or 3D?
2D
unity uses PhysX for 3d and Box2D for 2d, separate libraries separate settings
alright then. Not sure how that changes anything I suggested lol
Player Prefs would be better no? i tried to use that but its smh not working
its still saying 0 correct even if player 1 is guessing some correct
quick silly problem
after building the build and sharing it with my friend
after she opens the .exe file nothing happens, ever
any simple solutions i might be missing?
Like I said, Playerprefs would also persist after they close game, so just something to keep in mind
show me how you implemented it
tell them to check playerlogs maybe ?
Maybe show your implementation
they dont appear
the txt file ?
si, it doent appear in the data folder
AppData / localLow ?
Did you add/set the correct scene in the build settings?
should the game make any files there?
yes, it works for me, just not for her
yes, it should be the CompanyName you used
ideally a playerlog if it doesnt completly silently crash
%USERPROFILE%\AppData\LocalLow\CompanyName\ProductName\Player.log
i don't recall making a companyname and i cannot find anything like that in my locallow
is it necessary to be here and im missing it?
u gotta change ur Pc's name bro.. thats a gnarly profile name ๐
I think default is "DefaultCompany"
if you never set it
i dont know, i tried a lot, im pretty confused rn, but thats what i wrote
OH it isthank you
ur assigning the value to a local variable inside Start, it never escapes it
classic mistake
well there is only Player.txt with some two random paths
for your friend ? nothing inside ?
where do i put all of that otherwise hahahahahaha
just mono path and mono config path
for me there is a lot of stuff, for her nothing
Create variables outside of Start. Populate them inside Start
preferably inside a field
do they have a firewall / something blocking the program from running? since its gonna be unknown publisher (not signed)
worth checking
build works for me, she also has 64-bit, no antivirus on, could windows firewall be blocking it?
it would prompt you to allow it
can they run other unity games?
never tried before
or any other 3D games
i actually dont know what to do lol
do you know how to make fields inside a class
she must have
private float makeYourVariableHere;
void Start(){
makeYourVariableHere = AssignYourVariableHere;
}```
if its a public variable you can access it outside the class, as long as you have a reference to the class its within
myScript.myVariable = newValue;
how i can remove this line from my wheelcollider?
collapse the component
yes, but still i have no clue what to do
or go in here and find the component to disable
hm, it actually works for other people, just not her, so it makes sense that it should be something like a firewall?
ya, its most likely something on her machine
does it even show that it starts up? could check in the taskmanager
how would i go about checking in task manager whether it starts in any capacity?
do i stay in details and look for the slighest change? there must be an easier way right
might help
should just pop its head up in ur processes
you'd know if it even starts running (im doubting it does)
well it doesn't appear there so unless it starts for a milisecond we wont know
i suppose it just doesnt
I am trying to get a audio slider funktion but it is not working
ya, i think even if it insta crashes the task manager would show it red-lining ur ram for a second before closing lol
very useful info
i dont think its running.. try right clicking and running as administrator?
tried it, i think i got her to turn off all firewalls and antiviruses, still nothing
also configure your !Ide
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
โข Visual Studio (Installed via Unity Hub)
โข Visual Studio (Installed manually)
โข VS Code
โข JetBrains Rider
โข Other/None
very odd
what
What calls ChangeVolume? What calls Load?
MonoBehaviour gave you away.. in urs it's not colored
he says it was crashing, so doesnt sound too similar, hers doesnt even start
and i dont want her to underclock her gpu for me ๐ฅน
true, im just lookin at all avenues
what I tried doing it yeasterday n I thought I did it
what ide is that?
VSCommunity
ah
I installed some add ons too
the text looks similar to vs code
that sounds pretty silly too
it is not configured
no clue watched a video on having the slider UI be connected to the script
then you are just blindly copy&pasting the code
and did you do that
thats nutty lol
I dont really know coding I just gotta get this slider working
If im making a menu with multiple stages (such as one to click play/options/quit and another stage where players can enter their names) should i split them into different scenes and go through the scene manager order? or is there an easier way where they stay in the same scene
get your ide configured first @proven junco
So I'm trying to learn some super basic game stuff and following a tutorial. I go into VS to add some code for movement but things like Vector2 arent changing color like in the tutorial. I have the unity plug in checked and updated on the VS installer
!ide
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
โข Visual Studio (Installed via Unity Hub)
โข Visual Studio (Installed manually)
โข VS Code
โข JetBrains Rider
โข Other/None
!ide
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
โข Visual Studio (Installed via Unity Hub)
โข Visual Studio (Installed manually)
โข VS Code
โข JetBrains Rider
โข Other/None
man I tried and I thought I did 
ok, so your try wasn't succesfull
dont think - check
anyone know?
should i just use different scenes for every step in the menu
A couple of ways to configure Visual Studio and Unity.
- You already have Visual Studio : 0:25
- You need to download Visual Studio,
- through the Unity Hub : 2:09
- through Visual Studio's Homepage : 2:49
Visual Studio Download Page :
https://visualstudio.microsoft.com/downloads/
also can variables carry over into different scenes
such a google questions you are asking
just try to googile it first
I promise unity was attached yeasterday
is there anything wrong abt this? i genuinely cannot see it, first pic is mine, 2nd pic is the tutorial
sure, you can.. while doing a menu system i ended up using additive loading.. to load multiple scenes at once..
you cna clearly see a red underlined error
if statements dont want ; right when you open it
i had one scene that had DDOL objects that i could store my data in..
Try looking at the things that are underlined in your code. Start from the first one, since one issue often casues another
Was it a crash or was it the warning about the application not being signed/safe/trusted etc?
nono, i was talking about the guy from the link,
for my friend it doesnt even start
Also,
Number of times it wasn't exactly like the tutorial: 150
Number of times it was exactly like the tutorial: 5
Number of times the code literally did not exist: 1
2022-07-19 to 2024-3-21```
trying it but it doesnt bode well
Number of times the code literally did not exist: 1 lol i want to hear that story someday xD
like i said, im just sending any solution i find lol.. since not sure why it would run on ur machine and not theirs
if its the exact same build
maybe they just have a crappy potato ๐
Code Monkey tutorial on an online lobby that literally made the lobby script "An exercise left up to the viewer" despite the other code directly referencing specific properties and functions from it
the game really really doesnt require a strong machine
its ultra basic
Maybe reboot the computer? If they rejected it the first time, it may continue to block the application if an attempt is made to run it again.
Never shown in the video, not on the github
trying it rn ๐ผ
they do
theres a visual studio package especially for linking to unity, so they are meant to be together forever
still nothing :( exe doesnt start
well I installed unity pack and connected yeasterday and it was working
but not today
no.. make sure on ur current open project you set it to be VSComm in the External Editor drop down in the settings
keep regen project files
until it stubbornly accepts
yeah I know It was selected yeasterday
๐ yea just regen the files.. and make sure not to change it back before u close unity
I only had to do it again today
i find a good restart of unity / vscommunity/ sometimes the machine all at once solidfies things
do I need to do some special to regen files
everytime I've closed?
Yeah strange
that external script editor can be set to any executable in theory. Unity just executes the program and adds the path to the opened file to the args 
did u restart it?
aye that ones right
yay
its now configured
now fix the errors
There you go, now your error is underlined in red
and dont use player prefs...
and make sure ChangeVolume is being called
; say what?
huh? why
cuz he's gonna say use JSON
why
its fine for a newbie
also there is a typo in your player prefs saving
prefs
sometimes you have "volume" sometimes "Volume"
many ways
not something you would be intrested for now, using prefs is completely fine for a begginer
data contracts are pretty cool, Unity also has a built-in JSON class
there are "Volume" and audioListener.volume and ChangeVolume
player prefs is just hackable since code can be injected into it, but its fine if you are starting
and json isnt? lmao
ya ^ just remember if ur saving ur remaining lives in playerprefs..
thx
imma have an infinite lives hack
anything on client is hackable..
obsfucation
not even
obfuscation?
Since you're using that "Volume" string a few times, consider making it a const value, so you onlyhave to modify it once to reflect changes everywhere
thats why you use data bases if you are a large scale company
yo my game gon be on itch so hackable either way, Im I right .... ha ha ha ha
MongoDB free database ๐
You're thinking of binary serialization. The issue with PlayerPrefs is that they persist after deleting the game and storing too much is just a leech on your player's hard drives
or make your own
as if
buy a server, get linux running, etc etc
Not this shit again...
There is no way you are suggesting this to a guy who just got his ide configured
yeah your db will be hacked in minutes
Plus not all of binary serialization has vulnerabilities, just BinaryFormatter...
You can use a BinaryReader/Writer just fine
yea don't use BinaryFormatter
yeah Imma just make a server while I'm at it
just use player prefs
you are fine
a game obviously had to be breached for people to find out how unsafe binary formatters are
i wonder
that has nothing to do with games
the thing that binary formatter is unsafe and dangerous has nothing to do with games and game development
People thinking C# is only used for making games be like:
is this the unity version of json?
yes
prettyprint
i had tremendous help building my save system
i dont know why unity has one when there is a perfectly good one in the system namespace
Unity's is faster
aye!
You should really stop worrying about breaches. Its seemingly mentioned everytime saving comes up. This is a fact: any offline game can 100% be "hacked" and any data can be injected/modified. No ifs buts or ands.
the guy that helped me build mine has a few published games so i trusted he knew best
Is there a reason to use Slerp over RotateTowards? Also, what defines the up axis for RotateTowards, does it just Vector.Up the space that it's in?
Same reason you'd use Lerp over MoveTowards
They do different things. One of them gets a value some percent of the way between two values, one of them moves towards a value without exceeding some defined maximum
Slerp is great when you know the start, end, duration and if you want to apply an easing function of some kind
ya, true.. i construct my quaternions/rotations before hand. and then feed them into slerp
found thats the best way for me
Well, one thing I don't understand is that you define the up axis of rotation with Slerp, but RotateTowards you dont
i use slerp for all rotations.. even if they dont need it, the fact that i could smooth it later is always a plus
You don't define any up axis ๐ค
you just give start and end rotations
What do you mean, there's no "up axis" in slerp
Are you thinking of LookRotation?
oh ok right it's look rotation I am defining the up axis
maybe the better question is, I want to Slerp on both the y and the x (to tilt forward and down), but getting some unintended behavior
Slerp takes two direction vectors, it doesn't operate on individual axes
Yeah, so do I make two look rotations and apply slerp on that rotation twice with different look rotations?
back again, what do I do
You give it the start direction, the end direction, and the percentage of the way between them
hehe, im already getting anxious thinking about it
What's line 37 of SoundManager.cs
๐ 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.
how do I do
Read the bot message
volume slider will be null
youtube did not teach
Show the tutorial
and show a screenshot of your inspector for this script
muahah i feel a list addition
right, but if I do
targetRotation = Quaternion.LookRotation(targetDirection, Vector3.up);
then slerp this towards the direction, it will only rotate on the world axis (in global)
u hadn't assigned ur volume slider as mentioned
it don't know which slider is volumeSlider
it's like I want to do:
targetRotationY = Quaternion.LookRotation(targetDirection, Vector3.up);
targetRotationX = Quaternion.LookRotation(targetDirection, Vector3.right);
That will be the exact Quaternion you'll get when the t parameter of Slerp is 1
In this unity tutorial, you'll learn how to make a volume slider for your game. Adding a volume slider in your game settings gives players the option to play with or without sound.
โคAdding BGM and On/Off Sound Button - Easy Unity Tutorial: youtu.be/AFcHsKd_aMo
Timestamps:
0:00 Intro
0:11 Volume Slider UI Setup
0:46 Sound Manager Scripting
3:26...
Show the inspector of this script in your scene
watch 3:16
Stone Cold?
lol i thought that too
this is not the requested inspector
attach the script to the entity and then slide the slider onto the variable in the now created script component
nothing
Unity 101
Number of times it wasn't exactly like the tutorial: 151
Number of times it was exactly like the tutorial: 5
Number of times the code literally did not exist: 1
2022-07-19 to 2024-3-21```
well I did asign now
well, that error will be gone ๐
lol
New Boss Enter
yeah
I was joking
ha ha ha
found it
Now I have to make an menu with audio slider in the gane to
game
part of coding is designing things to be easily copied
u should have the bulk of it ready now, since u just did it
Yeah Probb easy task
Hello, I don't want to interrupt anything but I am currently struggling with making a little menu in the FPS microgame template. The issue I am facing is that I can click through my menu when it is active. I tried to copy the way the pause menu works from the template itself but for I can't seem to figure out where they prevent the player from clicking through the UI. Here is the code I am working on https://hastebin.com/share/jazipicope.cpp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
cool
do u have an EventSystem in ur scene?
yes
but that was already there as part of the template
oh and I can use my menu when the pause menu is open
i need help, why cant I update the VS Code package? It says on the documentation it needs to be a newer version, and even warns me so in vs code.
is there any shortcut for scenes in unty
It is deprecated. Now VSC uses the same backend as VS, so you need the Visual Studio Editor package
"for scenes" ... what?
oh, I see, thank you
your question was stupid and doesn't make sense.
What is a "shortcut for scene"?
what do you want this shortcut to do..
shortcut for scene
no, there are no shortcuts to quickly load scenes
alr
In Blender it [numpad] just orients the view, it does not change scenes?
I don't think Blender has a concept of "scenes"
It's very much not the same concept yep
The closest analogue is opening an entirely different .blend file
which there is not a shortcut for
there's an asset on the UAS that does quick loading / swapping of scenes..
okey well it was an refrense
Quaternion rot;
void RotationMethod1
{
Vector3 targetDirection = (newTarget.Transform.position - transform.position).normalized;
Quaternion targetRotation = Quaternion.LookRotation(targetDirection, Vector3.up);
rot = Quaternion.Slerp(rot, targetRotation, speed * Time.fixedDeltaTime);
targetRotation = Quaternion.LookRotation(targetDirection, Vector3.right);
rot = Quaternion.Slerp(rot, targetRotation, speed * Time.fixedDeltaTime);
transform.rotation = rot;
}
//don't believe this is the ideal way
void RotationMethod2
{
Vector3 targetDirection = (newTarget.Transform.position - transform.position).normalized;
Quaternion targetRotation = Quaternion.LookRotation(targetDirection, Vector3.up);
targetRotation *= Quaternion.LookRotation(targetDirection, Vector3.right);
rot = Quaternion.Slerp(rot, targetRotation, speed * Time.fixedDeltaTime);
transform.rotation = rot;
}
void RotationMethod3
{
Vector3 targetDirection = (newTarget.Transform.position - transform.position).normalized;
Quaternion targetRotation = Quaternion.LookRotation(targetDirection, Vector3.up);
Quaternion temp_rot1 = Quaternion.Slerp(rot, targetRotation, speed * Time.fixedDeltaTime);
targetRotation = Quaternion.LookRotation(targetDirection, Vector3.up);
Quaternion temp_rot2 = Quaternion.Slerp(rot, targetRotation, speed * Time.fixedDeltaTime);
rot = rot1 * rot2;
transform.rotation = rot
}```
So between these three methods, what would be the solution to how I want to combine these slerp rotations every frame, or what else should I consider cause all my testing coming out pretty bad.
so that my "stupid" question could be understood
Why do you keep doing two LookRotations?
And why with one using Vector3.Right as up?
because Vector3.up look rotation only seems to rotate me on the world up axis
And I still don't understand it, because what you want to do and what Blender does is different. Blender has no concept of scenes, so do you want to open another scene from the code, or move the camera in the currently active scene?
I need both y rotation and x tilting rotation
No, the up you give it there is to set the roll for the resulting rotation. LookRotation creates a quaternion such that it's forward is the given direction and it's local up is oriented towards the given parameter
perhaps something else wrong with my logic, because what I am applying it to is being stubborn and only rotating one axis
Quaternion.LookRotation(targetDirection, Vector3.up) will produce a quaternion of this object, looking straight in the targetDirection, while still staying upright
Quaternion.LookRotation(targetDirection, -Vector3.up), for example, would have it pointing the same way, but upside-down
hi when i try to bake a object navmesh i the buton doesnt give me the option to what should i do
Hmm, alright, so slerp should technically get me to the point where I am directly looking at it, but it has some different orientations for how it will do that eh
i put it in a separate script and referenced the game object component and still no luck.
foreach (Collider2D collider in colliders) {
if (collider != null) {
GameObject parentObject = collider.transform.parent.gameObject;
SpriteRenderer parentSpriteRenderer = parentObject.GetComponent<SpriteRenderer>();
if (parentSpriteRenderer != null) {
parentSpriteRenderer.sprite = null;
}
Destroy(collider.gameObject);
pm.CreateDust(collider.transform.position);
}
}```
yup thanks for help
where did u go buddy (on runtime after a click)
So, picture a tennis ball with a nail sticking out of it. You can rotate the ball so that the nail is pointing due north, but notice that you can spin the ball however you like by twisting the nail. This is why you can't get an orientation with just one axis. If you instead put a second nail somewhere in the ball, and made sure that second nail was pointed straight up and the first one is pointed due north, you can't rotate the ball any more without invalidating one of those conditions. That's why you specify two vectors for LookRotation
so far I've only used coroutines with waitforseconds, which is pretty straightforward. However, I've seen examples online that looks like this:
IEnumerator MyCoroutine(){
while(true){yield return null;}
}
Although I know coroutines are used for executing code asynchronously, I don't understand why while(true) doesn't result in an infinite loop
If you frequently forget that you're in play mode, you can configure the color the editor tints itself with when in play mode. The default is very subtle.
Either you set pm to null or pm is destroyed
You yield return null; every iteration of the loop.
A while loop that does nothing at all would, indeed, freeze your game.
which is a bad thing?
The yield return null means "Wait until next frame to do anything else here". This means it does one iteration of the loop per frame, kind of like a mini-Update
most gamers do not enjoy the game not running
I did answer a question once where that was the desired outcome.
In an enumerator, yield halts the method and returns control to whoever called MoveNext() on the enumerator
They were making a meta horror game and needed a way to force a game crash and asked for ideas
I see, so it essentially is an infinite loop, but only executes once per frame if I'm understanding correctly
I told em "just stick in an while true loop"
It's an infinite loop that takes a nap every iteration
so yeah
Yep. It will do one iteration per frame for ever, so there's plenty of time for all the other stuff to run in the meantime
i never made it null. Not sure what's going on with it...
Right, I guess there's more flawed somewhere in my logic, but beyond rotating with a single look rotation and adding forward offset, the object that's rotating eventually gets to the point where it only wants to rotate on the y axis and not the x. Specifically for projectiles that home onto their targets.
until the user presses the X button on the top right of the window, or cancels it in task manager after freaking out that pressing the X button doesnt work because the app is frozen
Well, when a statement is true and one of the conditions in the or is false, then the other one must be
So, you want this object to rotate towards looking at newTarget over some period of time, yes?
I've tried both, but idk once the projectile overshoots it just wants to stay on the y
Well, either one could work, it'd just depend on if @timber tide wants a constant speed or constant time to reach the destination
indeed
sec let me chop up the code a bit
Vector3 targetDirection = (newTarget.Transform.position - transform.position).normalized;
Quaternion targetRotation;
targetRotation = Quaternion.LookRotation(targetDirection, Vector3.up);
homingRotation = Quaternion.Slerp(
homingRotation,
targetRotation,
currentHomingSpeed * Time.fixedDeltaTime);
Vector3 posChange = currentSpeed * Time.fixedDeltaTime * transform.forward;
transform.rotation = homingRotation;
transform.position += posChange;
that's basically only stuff I've acting on rotation and position at the moment
so basically the projectile spawns facing an incline and homes onto a target, but since the rotation speed can be slower/faster than the target, it can over/under shoot. And, the problem is that once it over shoots it does not want to correct its rotation and tilt upwards
Do you want the rotation to happen at a constant speed or do you want the rotation to reach the destination in a given time
Okay, so if you want the speed to be constant, RotateTowards is what you want to be using instead of Slerp
https://www.youtube.com/watch?v=G1AQxNAQV8g
Okey Im eithe like really dumb or something, I try to follow but he says pause buttom and shows a ui obj but does not say what it is, like hello
If you are making a game and need a pause menu, this video is for you. In this video, I teach you how to pause the game in Unity. Enjoy watching.
๐Subscribe to My Channel: http://www.youtube.com/c/SoloGameDev?sub_confirmation=1
โค๏ธJoin My Channel to Support Me: https://www.youtube.com/c/SoloGameDev/join
โFor How to Make a Multiplayer Game in U...
I do get similar behavior with RotateTowards but ill try it out again
transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, maxDegreesPerFrame)
What do you mean "Does not say what it is"? Surely they say it's a UI object, since you seem to know it's a UI Object. What else would they need to say?
why everytime i open unity i get this error? Assertion failed on expression: 'SUCCEEDED(hr)'
I only know it is some kind of ui think bc of the inspector and the options that is has but he dpsnt say what it is
just "Pause buttom"
but WHAT is a pause buttom
A... button
it's a UI element called a.. button
an invisable button
lol
yeah but he has two diff sections of buttons
one pause menu buttons
and then pause button
anyway this is code related channel
well it is code related
and your questions doesnt make sense
then show the code
is there a way to connect this transparent box to the red enemy to use as a vision cone?, he goes through waypoints so i would also like him to turn at corners
is there a way to test if an Axis key is released like Input.GetKeyUp?
axis can't be released its a.. axis
not a key or button that can be phyiscally released
you can test if the getaxis returns 0 for example
If by "connect" you mean "make this move when the enemy moves" then make it a child object of it
Axes don't have a press or release state. Check if the axis's value is 0 to see when it's "released"
i was asking if it had a way to tell if the axis wasn't having one of its input keys pressed
that worked thanks
Anyone know why I am clicking through my ui menu back into the game instead of on the ui?
Does the UI have raycasttarget enabled? Do you have an event system in the scene? What layer is the ui on?
The UI is on the second layer, there is an event system but I am not quite sure where the raycastTarget setting is supposed to be
there is a graphic raycaster component on it with the blocking mask set on everthing
Found it! Raycast Target is enabled on all the elements
if it helps I am using the FPS microtemplate from unity and the pre existing pause menu does work in it and even makes my menu work when it is enabled in the background
could it be caused by having a second canvas in my scene?
I added a new scene to my game. The build works as intended but the play test is still stuck on the previous scene indexes.
did you add the scene to the scene list in the build settings?
yes, although i do realise instead of saying Scenes/scenename, it says Player1 Name, which is the name of that scene
that's just the path to the Scene asset
yeah but it doesn't have that path on the new scene that i added
Screenshot the scene list for me.
hi
hi i cant get the agent to move in the navmesh, i have baked the mesh blow him and its blue but i cant get him to walk
in need help
Okay, so the scene named "Player1 Name" should be loaded when you load scene index 1
Failed to defeat the Leshy, maybe next time โ๏ธ๐ฅณ
New enemy: Leshy
Game name: FolkOrigin - on Steam
---------------- add to wish list ------------------
https://store.steampowered.com/app/2863790/FolkOrigin/
I am creating game together with my brother ๐, it is strategy game combined with an RPG game.
My: Unity + C#โ๏ธ
My brother: art 2D๐จ
More information soon...
#FolkOrigin
FOLK ORIGINFolk Origin is an RTS game with an RPG flavor, in which the entire world is set on a 2D hexagonal map. The main goal is to expand the settlement in such a way as to ensure the production and extraction of as many resources as possible on the map. A well-planned distribution of labor results in the effective acquisition of resources ne...
Coming soon
yeah
I'm trying to make a 3D model run on a 2D screen but it doesn't work

Looks like it's working just fine you're going to have to say what the actual issue is
fixed! Instantiated a prefab for the effect instead, and it deletes after with the deleted block Performance efficient solution ๐
What behavior are you observing in the editor and in the built game?
No, when I start the game it disappears
the built game runs the scene order fine (although there is another issue with an input box) however the editor doesn't load the scene entirely and skips to the next scene
Show the code that loads the scene.
Well, with all of the information provided, the only thing I can possibly answer is "Is it actually somewhere visible to the camera"
Log the currently active scene and its build index before calling LoadScene
See what value it actually has in the editor.
i'm using waypoints to make this enemy move, how do i turn the field of vision block when its going a certain direction instead of having it at the front the entire time
okay, but the build settings shows it is 0 and it should load 1 by the code logic
right, but what value do you actually get in the editor?
was this wrong
I forgot that the scene object alone wouldn't tell you anything; i should've said the name and the build index
nvm i see the issue
vision block?
Parent the object to the enemy and then make the enemy rotate.
I don't use build indices in the editor. Maybe they can be wrong until you restart the editor or something
how would i do that while it's walking though?
thanks ill try that
You can use Quaternion.LookRotation to compute a rotation in the direction of movement, and then use Quaternion.RotateTowards to steadily rotate the enemy towards that rotation
is it not parened? it should move with it
it is, it moves with it
Quaternion target = Quaterion.LookRotation(direction);
transform.rotation = Quaternion.RotateTowards(transform.rotation, target, Time.deltaTime * 90);
just does not rotate
Note that this will make the enemy tilt up and down if the destination is above or below them
If you don't want that, consider...
is the enemy rotating then
direction = Vector3.ProjectOnPlane(direction, Vector3.up);
This will throw out the up-and-down part of direction
I guess direction.y = 0 also works ๐
the new scene i added is in bold
I haven't used unity in a while so maybe i added the scene in a different way?
where would i put this in the code? im not that good with coding sorry\
Ah, I get it
you have multiple scenes loaded
or would it be a seperate script?
you're not rotating here ofc the box would not rotate as well
"Player1 Name" is the active scene.
put it in update
If you don't want to actually have multiple scenes open for editing at once, just close the others in the editor
You've dragged the scene assets into the hierarchy window to open them like that
yeah it worked, i just unloaded the scenes i don't want active
but I have an issue with an input text box not appearing when I load the game, any ideas why?
I prefer to not look at the active scene index; I just directly go to the scene I need
is this how id do it?
im checking for null but its still throwing an error
sorry nvm just googled it
It's not null. It's destroyed
If this is an expected outcome, the object being destroyed, you can do != null. Unity has overridden the == operator to work properly for destroyed objects, but the C# implicit cast doesn't
Im not destroying it, its has a ddol, and im just trying to deactive it
i know there error says i am
The error is pretty specific in letting you know it's been destroyed
You would store the string or int probably
but i have not writen any code to do it
Show the !code for PlayerController
๐ 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.
This script doesn't seem to have a DDOL in it anywhere
[SerializeField] string SceneName = "MyScene";
public void Method()
{
SceneManager.LoadScene(SceneName);
}```
Several things.
- Why are all your prefabs of type
GameObjectif literally the first thing you do with them is GetComponent - Why are you setting
instanceinside of this script when (presumably) all of these scripts setinstanceinside of their own code - Why is this object a DDOL and none of the things it's spawned?
Number 3) im trying to load a battle scene, and i dont want to craft in that scene nor use that type of inventory. Battle scene is the only exception where the ddol is not needed
number 2) i do need to refactor.
number 1) again i will refactor
You're treating your PlayerController.instance as if the player controller is a DDOL, but it isn't. Changing scenes destroys PlayerController.instance
when you say its not a ddol. i know im not setting it in the player controller. but i am in the Essentials loader am i not?
well im setting the essientals loader as a ddol
You are setting the EssentialsLoader to be a DDOL
Is that not a good way to do that?
I mean, does it need to be a DDOL? There doesn't seem to be anything relevant on this that would need to persist between scenes. It doesn't even hold any data
Why did you make the EssentialsLoader persistent but all of your singletons not be
No true but when i go into a new scene or create a new scene. i was thinking it would be easier to use the essientals load as it holds all my UI stuff. then i dont have to add it to a new scene each time.
Ok, I figured it out. Apparently unity's rigidbodies was fighting with my navmesh (I've not used unity's for a while), and it seems like the transform values I was sampling was not the same as the ones that I was debugging/displayed in the editor
It doesn't seem to hold anything. Although I suppose it's possible you put this on your canvas or something
but RotateTowards does make more sense so I'll stick with that.
So if you was building or have built an rpg game. would you manually add the player the ui to each scene? When you say data also. the game manager does keep track if a battle is active and the inventory menu does keep track of what items i have
It's very simple:
Does this object need to exist in multiple scenes? If so, then make it a DDOL.
so or though i wont use items in the battle when i go back into the scene world i do want to be able to craft again
Nothing you've shown of EssentialsLoader indicates it should be a DDOL at all. All it does is spawn in a bunch of prefabs when the game boots and then do nothing else ever again
Does anyone know what code it is to give roles
Like bartender or manger stuff like that or vip
make an Enum ?
What does that do
Lets you define ints with names basically
IEnumerator HomingAbility()
{
while(true)
{
do
{
int randomFrames = UnityEngine.Random.Range(1, 4);
for (int i = 0; i < randomFrames; i++)
{
yield return new WaitForFixedUpdate();
}
} while (!isHomingAllowed);
//home onto target;
}
} ```
When I deactive this, it will exit out of the yield and won't re-enter when I flip it back on, right? So I'd have to call the coroutine again when I activate it
trying to spread out some work over frames cause it is a lot of projectiles
don't think so, but also why not test ๐
ive already frozen unity once testing some stuff haha
I was under the assumption when you deactivate it basically runs something like StopAllCoroutines
By 'it' do you mean isHomingAllowed?
I am unsure what this is supposed to be doing.
someone got a video on how to choose fullscreeen mode or windowed
Also, if isHomingAllowed is true, there's no yields, so it'll go infinite
kinda stuck on that
it's not supposed to exit out of the ienumerator and it will always yield at least 1 frame
there are plenty, what did you search?
Where
Presumably there's other code where the comment is
Ah, probably
"choosable fullscreen mode button unity"
the do while will always fall into the for loop
at least 1 frame (there is no waitforframes(int num) so this is my solution)
i mean, why not just
"FullScreen Switch Unity"
"Making Button Unity"
combine the two
do i put this on a button?
You call this wherever you want to change the full screen mode
it's an infinite coroutine, and it's to control overlap sphere operations every frame cause I don't really need to update the rotation that quickly
I'm searching for a menu button script that allowes me to put a button into work by pressing it and activating fullscreen or windowed
why not just use a Toggle
thanks got there
Once you know how to run code from a UI button you can do literally whatever you want on a button press
I did find one with toggle but it didnt work
the input field and the border around it (below the text) doesnt load when i play it
but I will try to make my own code
I have the following code that starts a coroutine which is supposed to call the method AssignMeshData after the vertices have been defined
//called on button click
private void CreateMesh()
{
_meshDataCS.CreateVertexBuffer();
StartCoroutine(AwaitComputeBuffer(_meshDataCS));
}
private IEnumerator AwaitComputeBuffer(MeshDataComputeShader meshDataCS)
{
while (meshDataCS.vertices == null)
{
yield return null;
}
AssignMeshData(meshDataCS.vertices, meshDataCS.uvs);
}
However, it only appears to work when CreateMesh is called a second time, but doesn't work when called the first time
any ideas?
vertices are assigned on line 84 https://gdl.space/oqositorip.cs
Yeah I made my own code and feel like a god
but thx for the help either way
hi same question from earlier but now it clips in the ground
if i can give more context for help i will
More context? Maybe start with the context.
if you're wondering why serializing a Scene didn't work, that's because Scene is an object that represent a runtime scene (the actual data Unity creates when it loads a scene)
If you google "unity scene field" you'll find a thread on the unity forums talking about this
there's a nice "SceneField" script in there that can be used to pick a scene in the inspector
Also, @vale geode , I suggest you remove the inappropriate stuff from your server profile.
i trying to make the nav mesh agent follow waypoint in the scene ,i have baked the scene already and yeah thats it, but im stuck and i cant figure whats going on, the tutorials i follow dont seem to have the same problems and no errors on console
Looks like the pivot for your character is too high
also why is there a giant box collider
is it supposed to be below ground?
dont know but il make it smaller if it helps
you just added something without reason?
@rich adder yaw its been 4 days i still dont knoe womp womp
it afects the mesh?
not really but it might affect collision wrong just remove it and put capsule if you want collider on it
fix the mesh , you haven't shown how you put mesh
i imported a fbx from blender, the origin is on ground level and removed the colider but it didnt change
where at ? also the pivot mode should be Local not Global
seems you got something tilting forward but gizmos shows upright
looks like this when not in play
you probably baked the navmesh wrong / tiled maybe
I entered one scene by accident and now cant access multiple scenes at a time
how can i return to that
the hierarchy just shows the one scene rn
nvm got it fixed
is code monkey a good place to start for someone who has no clue what unity is apart from that it makes games?
no.
!learn
:teacher: Unity Learn โ
Over 750 hours of free live and on-demand learning content for all levels of experience!
what's this
lemme check it out
proper way to learn unity, start with the essentials pathway first
TMP_Text
underlined in red though
also the input field needs one
i did google this btw
What fixes does your ide suggest? What ide is that even?
asks me if im missing a directive
idk if i am
screenshotted to show the ones im using
also the ide is configured, it is vs
code
found the issue
It should give you a suggestion of how to fix the issue or what namespace to use.
using TMPro was necessary
As for the other one, you can look for it in the docs:
https://docs.unity3d.com/Packages/com.unity.textmeshpro@1.0/api/TMPro.html
void Start() {
// Display results, for example, using UI text elements:
player1ResultsText.text = "Player 1: " + player1Score + " correct answers";
player2ResultsText.text = "Player 2: " + player2Score + " correct answers";
// You could also display who won or if it's a tie
if (player1Score > player2Score) {
winnerText.text = "Player 1 Wins!";
} else if (player1Score < player2Score) {
winnerText.text = "Player 2 Wins!";
} else {
winnerText.text = "It's a Tie!";
}
}
public void CheckAnswerAndUpdateScore(string selectedAnswer)
{
// Assuming 'actualAnswer' holds the correct answer (e.g., "A", "B", "C", or "D")
// This value should be set whenever you generate/load a new question+
// Example correct answer
// Check if the selected answer matches the correct answer
if (selectedAnswer == QuestionGenerate.actualAnswer)
{
// Correct answer, increment the score of the current player
if (currentPlayer == 1)
{
player1Score++;
PlayerPrefs.SetInt("CorrectAnswersPlayer1", player1Score);
}
else if (currentPlayer == 2)
{
player2Score++;
PlayerPrefs.SetInt("CorrectAnswersPlayer2", player2Score);
}
// Optionally, you can add feedback for the correct answer here
Debug.Log("Correct! Player " + currentPlayer + "'s score: " + (currentPlayer == 1 ? player1Score : player2Score));
}
else
{
// Wrong answer, add feedback or handle accordingly
Debug.Log("Wrong answer.");
}
// Ensure to save the updated scores
PlayerPrefs.Save();
}
// Update is called once per frame
void Update()
{
if (totalQuestionsAsked >= 4) {
// Save the score for the current player
PlayerPrefs.SetInt("CorrectAnswersPlayer" + currentPlayer, currentPlayer == 1 ? player1Score : player2Score);
PlayerPrefs.Save();
// Reset for next player or end game
totalQuestionsAsked = 0;
correctAnswers = 0;
displayingQuestion = false;
if (currentPlayer == 1) {
// Switch to Player 2
currentPlayer = 2;
UnityEngine.SceneManagement.SceneManager.LoadScene("ZwischenScene"); // A scene where Player 2 gets ready
} else {
// Both players have played, go to results
UnityEngine.SceneManagement.SceneManager.LoadScene("EndScene"); // The scene where you compare scores and show results
}
return; // Prevent further execution in this update
}
// displayingQuestion = true;
i dont get why it issnt working, in "ZwischenScene" it doesnt show how many player 1 actually correctly guessed, it just says 0.
can smn help me out?
Wat? ZwichenScene?
so, the game is asking 3 question, which can be answered wrong and correct.
after these 3 question it switches to a scene, where it shows how many questions you have answered correctly.
but its just saying 0 no matter what, so i guess i did something wrong
update i checked the navmesh suface and baked again did see changes on the rotation of the colider of the navmesh agent, but the model it self rotates 90 degres and it still doesnt follow the path im going to rotate the model from blender and import again to see if thats the problem
What scene is the code above from..?
You set Int but never load it
why shouldnt it load there ?
it should load on the scene change no?
where are you loading anything to make it not 0 ?
yeah where is PlayerPrefs.GetInt
you've been told a few times how to share code here
what
!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.
it just load the saved no
using System.Collections.Generic;
using UnityEngine;
public class PauseMenu : MonoBehaviour
{
public GameObject pauseMenu;
public static bool isPaused;
void Start()
{
pauseMenu.SetActive(false);
}
void Update()
{
if (Input.GetKeyUp(KeyCode.Escape))
{
if (isPaused)
{
ResumeGame();
}
else
{
PauseGame();
}
}
}
public void PauseGame()
{
pauseMenu.SetActive(true);
Time.timeScale = 0f;
isPaused = true;
}
public void ResumeGame()
{
pauseMenu.SetActive(false);
Time.timeScale = 1f;
isPaused = false;
}
}
where are you loading to make it not 0 when you switch ?
no pause menu when pressing esc
but why sould it be wrong to use getint in start??????
what?
Start debugging the script
how I do that
Put logs. inside the methods, make sure everything is running
PlayerPrefs.GetInt is in start.
where
maybe send the correct script ?
yeah ok but its still not working with that
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class QuestionGenerate : MonoBehaviour
{
public static string actualAnswer;
public static bool displayingQuestion = false;
public int questionNumber;
public static int totalQuestionsAsked = 0;
public static int correctAnswers = 0;
public static int currentPlayer = 1;
[SerializeField]
private Text player1ResultsText;
[SerializeField]
private Text player2ResultsText;
[SerializeField]
private Text winnerText;
public static int player1Score = 0;
public static int player2Score = 0;
public int scorevalue;
void Start() {
// Correctly update class-level static variables from PlayerPrefs
player1Score = PlayerPrefs.GetInt("CorrectAnswersPlayer1", 0); // Use default value of 0 if not set
player2Score = PlayerPrefs.GetInt("CorrectAnswersPlayer2", 0);
// Display the scores using the updated static variables
player1ResultsText.text = "Player 1: " + player1Score + " correct answers";
player2ResultsText.text = "Player 2: " + player2Score + " correct answers";
// Determine who's winning and update the winnerText accordingly
if (player1Score > player2Score) {
winnerText.text = "Player 1 Wins!";
} else if (player1Score < player2Score) {
winnerText.text = "Player 2 Wins!";
} else {
winnerText.text = "It's a Tie!";
}
}
public void CheckAnswerAndUpdateScore(string selectedAnswer)
{
// Assuming 'actualAnswer' holds the correct answer (e.g., "A", "B", "C", or "D")
// This value should be set whenever you generate/load a new question+
// Example correct answer
// Check if the selected answer matches the correct answer
if (selectedAnswer == QuestionGenerate.actualAnswer)
{
// Correct answer, increment the score of the current player
if (currentPlayer == 1)
{
player1Score++;
PlayerPrefs.SetInt("CorrectAnswersPlayer1", player1Score);
}
else if (currentPlayer == 2)
{
player2Score++;
PlayerPrefs.SetInt("CorrectAnswersPlayer2", player2Score);
}
// Optionally, you can add feedback for the correct answer here
Debug.Log("Correct! Player " + currentPlayer + "'s score: " + (currentPlayer == 1 ? player1Score : player2Score));
}
else
{
// Wrong answer, add feedback or handle accordingly
Debug.Log("Wrong answer.");
}
// Ensure to save the updated scores
PlayerPrefs.Save();
}
// Update is called once per frame
void Update()
{
if (totalQuestionsAsked >= 4) {
// Save the score for the current player
PlayerPrefs.SetInt("CorrectAnswersPlayer" + currentPlayer, currentPlayer == 1 ? player1Score : player2Score);
PlayerPrefs.Save();
// Reset for next player or end game
totalQuestionsAsked = 0;
correctAnswers = 0;
displayingQuestion = false;
if (currentPlayer == 1) {
// Switch to Player 2
currentPlayer = 2;
UnityEngine.SceneManagement.SceneManager.LoadScene("ZwischenScene"); // A scene where Player 2 gets ready
} else {
// Both players have played, go to results
UnityEngine.SceneManagement.SceneManager.LoadScene("EndScene"); // The scene where you compare scores and show results
}
return; // Prevent further execution in this update
}
is the script running in second scene?
yes
dont sharecode like this
and connected to ui
its too large
!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.
how many of these scripts do you have
how many scripts in the whole game?
these are static
public static int correctAnswers = 0;
prob not, wondering why you made them static
Start from debugging from both sides:
- Is the value saved at all?
- Is the correct value saved?
- Is it overriden later on?
- Is the value loaded at all?
- Is the value overriden later on?
i guess i went somewhere wrong
thanks :)
I guess that would mean that 2 is failing.
How is it that you're only debugging it now though?
why did you do it last minute 
yeah im lost
i can only work under strong pressure


nah i can still finish it, its almost done, but this is so annoying rn
Debug.Log your selectedAnswer and actualAnswer
make sure the values are what you assume them to be
i mean actual answer is correct ( i can see that from jsut playing )
huh thats 1 out 2
How is the actual answer correct if the debugs are not? Either you're debugging the wrong thing or confirming the wrong way.
yeah i dont get it
by playing, i can see that only the right answer is right, which tells me that the actual answers are correctly used
i mean my buttons are working with actual answer
what does it have to do with selectedAnswer
Why all the getcomponents. Why are your answerX variables already of type button
but where is selectedAnswer variable coming from
im not advancend
Instead of just logging "Wrong answer", why not log selected answer and actual answer
You've made it more complicated
beginners like to do that
So do you want solutions or do you just want validation
solutions ofc
So, log the values, see what they are versus what you expect them to be
yeah sad life
So it appears your selected answer is null or blank.
so where do you pass the selectedAnswer to CheckAnswerAndUpdateScore
Where do you call CheckAnswerAndUpdateScore
CheckAnswerAndUpdateScore is defined to an active GameObject in the scene
thats all i have with CheckAnswerAndUpdateScore
then how exactly do you expect selectedAnswer not the be null ?
what does it mean if the function name is in a darker shade
bcz its not working for some reason
it used to before
i think the shade of it and its functionlaity is linked?
anyone?
it means its not used anywhere
whats that even mean->
where is the function running from?
what do i have to do now??
how else is it printing Debug.Log("Wrong answer.");
pass the right string for CheckAnswerAndUpdateScore
how do i do that?
so im trying to get the collider to scale it to the pipe, but for some reason, the collider just isn't showing, why is that?
Show where you are calling this function
public class AnswerButtons : MonoBehaviour
{
public QuestionGenerate questionGenerate;
public void OnAnswerASelected()
{
questionGenerate.CheckAnswerAndUpdateScore("A");
}
you mean like this?
idk what to do
okay and what calls OnAnswerASelected?
bro what does calling mean
show me an example
i mean trough that now this happenms
If you don't know the very very basic words that make up the concept of programming I can't really help you. You literally don't speak the language
i only took german courses
issnt this the beginners chat?
and if you show me an example i will understand it xd
So, somewhere, you're passing in a blank or a null. Click on that log and look at the stack trace at the bottom. Show that
but if i clikc one answer, its being output several times instead of one time
You seem to have somehow disabled the stack trace in your logs. Try to find out how to get those back. It'll tell you what function is calling this one so you can see what's passing in a blank
oh
yo I have a problem with
my script
someone will help
now might be a little late but, do you happen to know any good tutorials regarding this? some sort of guide with visuals, would be helpful as im not the sharpest tool in the shed
What is the question?
the projectile does not destroy itself upon contact with the wall
Does the projectile have a dynamic rigidbody on it?
Do either have a trigger collider?
Look for it in the unity docs, there should be sample code
Ah, you move it with velocity. So I guess question 1 is yes
Is the WALL a trigger? Why use OnTriggerEnter here instead of OnCollisionEnter
Is any of your colliders a trigger?
i am crying
it works but the player passes through the floor
is it possible to disable the gravity of a 3D character controller?
What?
Please answer my questions
What do you mean with 3D character controller?
You have to add gravity via code if you use Move. So just DON'T do SimpleMove and don't add gravity
Yeah if it's CC, then just.. don't apply it
the player falls through the wall
That has nothing to do with what we were talking about. But ok, if you want to change subjects without answering me...
Does the player have a collider?
yes
Ok, back to my question earlier, IS THE WALL A TRIGGER. Please answer this time.
It should NOT be
yes
Don't make it a trigger ๐คทโโ๏ธ
If the info helps, im trying to make a vr ice pick climbing game using open xr tool kit
and right now im trying to apply force in the opposite direction of my ice picks
but gravity is weighing my player down
and im using the Character Controller
how do i fix this?
but then the bullet is not destroyed..
As I said, use OnCollisionEnter
Well yeahhhh
You have to look at the docs...
Google it for the right signature. It is not the same as OnTriggerEnter
public void CheckAnswerAndUpdateScore(string selectedAnswer)
{
Debug.Log("Selected Answer: " + selectedAnswer + ", Actual Answer: " + QuestionGenerate.actualAnswer);
if (selectedAnswer == QuestionGenerate.actualAnswer)
{
if (currentPlayer == 1)
{
player1Score++;
PlayerPrefs.SetInt("CorrectAnswersPlayer1", player1Score);
}
else if (currentPlayer == 2)
{
player2Score++;
PlayerPrefs.SetInt("CorrectAnswersPlayer2", player2Score);
}
}
else
{
}
PlayerPrefs.Save();
}
0x0000028b35b4a083 (Mono JIT Code) QuestionGenerate:CheckAnswerAndUpdateScore (string) (at ....QuestionGenerate.cs:62)
0x0000028b35b499eb (Mono JIT Code) AnswerButtons:AnswerB () (at ...AnswerButtons.cs:82)
the right one โฌ๏ธ
0x0000028b35b4a083 (Mono JIT Code) QuestionGenerate:CheckAnswerAndUpdateScore (string) (at C...QuestionGenerate.cs:62)
wrong one โฌ๏ธ
its somehow getting triggered twice, but where
https://gdl.space/buyadadasi.cs
thats my whole code.
If the info helps, im trying to make a vr ice pick climbing game using open xr tool kit
and right now im trying to apply force in the opposite direction of my ice picks
but gravity is weighing my player down
and im using the Character Controller
Its just the default character controller
And you want to disable gravity?
Yes
You have code that is applying gravity, CharacterController doesnt apply it by default. Add an if statement or something
Well that must be the default open XR stuff then
Not familiar but probably yeah
it's not illegal to edit it, swat not gonna swat you
I know lol
Ok I said this because I didnt know at some point I thought it was against the license to change downloaded assets code ๐
XD
where as now I just have one megaproject with all the assets and I just copy the code when I need it rather than to have to use all the other garbage in the package
cuz I dont need a 12th inventory manager, or a 6th basic controller etc or fixing someone else code
ugh
I hate this
I may just try to remove the character controller and make my own rigidbody movement
But that scares me, considering all the new names for VR stuff I have to deal with
Are you not able to find what is applying gravity is that the real problem ?
GetComponent<ContinuousMoveProvider>().UseGravity = false
?
No idea
could enable fly as well looking at the docs since it overrides gravity
possibly it would override conflicting code that does gravity as well if you dont know whats causing it
Why is actualAnswer static? Does every question share the same answer?
And as to the blank one, look for anything else calling CheckAnswerAndUpdateScore because it isn't in this script
This was the answer: GetComponent<ActionBasedContinuousMoveProvider>().useGravity = false;
And I think it works?
But also not really
Idk man
I've been dealing with this for 6h :(
Do I need to create a level management object that swap out tile or just making each level a separate scene?
second sounds easier
is system.serializable a c# thing or unity thing?
if its a c# thing how would I serialize a class myself?
ive not been able to find many articles on it because all of them are about unity
i have isTrigger turned on in my box collider but i cannot pass through it]
do you have another box collider on the same object?
that happens to have istrigger turned off
nope only 1 box collider
if you remove the box collider are you able to pass through it?
if (hasHitThisFrame)
{
rb.MoveRotation(hitRotation);
rb.MovePositon(currentSpeed * Time.fixedDeltaTime * transform.forward);
}```
Does rb methods usually resolve as soon as you call them such that transform.forward will be updated?
otherwise I guess ill add this to my backlog of tests to do
i can
stop the simulation and add the box collider back, set it to trigger before startingthe game
should be fine now
it should resolve immediately, i think transform.forward is a getter/setter that rotates(the quaternion) immediately
but you might need to check your script execution order
are there any scripts depend on the transform.forward of this gameobject?
beyond just adding constant forward speed, no
how do i create an ai npc that moves and acts by itself?
That's basically asking for wish. Be more specific
sorry uhmm I created a sprite that have all the animations but I dont want I would would be the one to control it. but instead it will just spawn randomly and do its own thing and maybe attack the player also
Then just do it step by step. Each of the thing u want it to do
I mean like the script in unity. Like the code to import it into the game. Is there a reference that you might have?
There are many ways to implement npc ai. I suggest looking up some tutorials. Also, research what ai techniques are there overall: state machines, behaviour trees, planners like GOAP, etc...
ahhh i see okie
also ai is a very hot suject atm so beware of wasting money on assets you don't fully understand
cuz a lot of them use AI as a buzzword
I just want it to spawn and do random things without me controlling it XD
Id start with rule based systems in all case you have to design and implement the rules. Id start with stuff like ai controller besides what dlich said
Man, just make the same u did with the player, but change the input with random values
at the end of the day it just the same stuff as you except without a keyboard. so if you have a controller that handle walking that would need to work without player input. So if you have no idea of what you want to do as a player you wont be able to have an AI do it either. AI assets dont make them magically know about your features/world, even machine learning require a lot of hand holding at the start to define goals
That's a very complicated thing to do you know
and nothing prevent you from starting with a bunch of if since your gonna need those rules later
It's like saying "I just want million dollar without doing anything. Am I asking for too much?". Obviously, that's a bit of an exaggeration, but the point is, "I just want it to do random things" is not a one click of a button thing. Neither it's one script. It's probably some 10s of scripts and a setup in the scene
- optimization do cuz game loop are under 1s so you cant spend 10s every tick in your game loop on AI so you have to fake a lot of AI ...
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("FingerTip"))
{
button.onClick.Invoke();
}
}```
Hey, i was watching a video on setting up UI buttons for VR controllers and he has this function in a script
However when i rewrite it IDENTICALLY it says onClick "onClick is obsolete. Use clicked instead (UnityUpgradable)"
however when i use clicked "The event 'clicked' can only appear on the left hand side of += or -="
clicked is from uitoolkit and onclick is from the unity standard gui manager. Are you sure you are using the same UI package as the streamer ?
Yea the problem was i did
using UnityEngine.UIElements;
and not
using UnityEngine.UI;
onClick is a UnityEvent. clicked is a C# event
But yeah you had the wrong one
oops
Well moment of truth if buttons finally work
Does "OnClick.Invoke" Still do the colour Changing properties?
No. The event doesn't do anything you haven't set yourself
damn i guess im stuck adding a box collider to every button
You shouldn't mix ui with physics.
i have to ?
to have Physical clickable buttons atleast from what i saw
Wdym by "physical clickable buttons?
I've got a halfway decent inventory system working right now, but my next step I've been struggling with, due to being unsure which route to take with it. What are some good resources that describe good current methods for handling dragging an item out of one slot and into another?
Should I be storing item data in a mouse-cursor-object? A temporary variable? An Event?
I'm sure I could muddle my way through one possibility or another, but without knowing which methods are good, and which ones are dead ends, in terms of implementation, I'm worried I'll pick the wrong idea to pursue and screw myself over.
so you are saying you are scared of learning/getting experienced in unity ?
even if you picked the perfect one you might realize at some point it's no longer what you want at a future point of time
just try to not waste 80$ on assets promising ultimate solutions of ultimate destiny
there are plenty of examples for many things on abandoned unity projects on github or youtube
It takes longer to unlearn bad habits and practices than it takes to learn good ones.
I haven't bought any assets yet, making everything myself from what resources I can find, so I prefer to learn from good resources, since a lot of the "tutorials" I've found seem to almost teach someone the wrong way to do something on purpose.
how do you know at this point ? You are gonna asks us about every possible approach you see which is subject to personal opinion when the true answer is best approach depends on your use case?
No, I only come here when I'm uncertain, because that's typically when someone would come to more experienced individuals to get pointed in the right direction?
there's a few ways to do it, but the (most) correct way is that your inventory should be functional without the UI
beyond that, it's really up to your design, but anything on the UI should not be considered required to serialize any data.
Yeah, that part is all good and done right now, I have an inventory system which, in pure data, can handle stacking, splitting stacks, moving, removing, and adding in various ways. I came here because I was uncertain what the best practice was for implementing the mouse as a tool to interact with it.
what operations are we talking about? Swapping data?
Currently, it can handle:
Adding an amount of items to the earliest valid slot
Adding an amount of items to a specific slot (and stacking if items already exist in it)
Removing an amount of items from the earliest valid slots (and spreading to multiple slots if need be)
Removing an amount of items from a specific slot (and optionally requiring that it be a specific item in order for it to do so)
Moving an amount of items from one slot to another
I'm investigating how to use the mouse to drag an element from one part of the UI to another, in order to move items from one slot to another, and what some common and "best practice" implementations of that would look like.
each inventory type manager should have a swap method with parameters from and to where you check if the item dragged onto it is compatable with the correct type
mouse drag would be considered UI such that you've slots (also UI) that corresponds to the inventory slot
so inventory slot 1 -> Inventory UI Slot 1
My UI already makes sure that all inventory slots automatically coincide with the child index of the slots that are displaying them.
for the most simpliest design I'd just give each UI slot the reference to the pertaining inventory and the slot index it corresponds to.
otherwise bind callback events if you care
I'm trying to figure out if my mouse cursor should have what is basically a "one slot inventory", so when you drag an item out, it leaves the inventory and enters into a mouse cursor object's inventory, where it can then be acted upon to swap it into a different slot, or if it should just hold references to the slots and amounts in question, and then perform the Item Moving function using that temporary data once initiated.
Because I can think of a few different ways to do this, but I don't know if any of them are beginners traps.
I personally only encountered implementations using raytracing and I dont like implementing it
Id rather use a container system with weight/# of items limit than this
IDragHandler event is fine, you drag the UI slot onto another inventory slot and you basically invoke the swap event on that slot which references the inventory it's bound to
Gotcha, so use the IDragHandler, and feed it variables based on what is being dragged, and what it has been dragged over, then fire once the drag event ends?
so example ->
Drag Slot1 InventoryA to Slot1 InventoryB
Slot1 InventoryB has a method that passes the information that Slot1 InventoryA has been dropped onto it
InventoryB resolves the swap operation (it should have information about InventoryA and the slot index dropped from the drop operation) and does a callback for slots to update
What does | do in code?
I might still need to have a "mouse slot" though, since my inventory can in theory split stacks. if only because I'd need to visually modify an icon as soon as an amount is dragged off of it, and create a new icon that holds the removed amount, right?
you have a fake drag icon yes
the whole visual aspect of dragging is just fluff, you technically dont need any indication that you're dragging to complete a drag and drop operation. The only thing that matters is IDrag and IDrop interfaces for the most part.
It cares where you clicked (get info from that if it has IDrag), and where you unclicked (read info into gameobject if it has IDrop)
Interesting. So basically, have a fake invisible icon as part of a mouse cursor icon, which only serves the purpose of displaying its variables for the event during dragging, but don't actually change anything until a valid swap is done.
you start a drag operation, enable fake item slot and change the sprite and text (if you've got stacks)
and follow the cursor
Yeah, thank you very much.
I don't know if this counts as spoonfeeding, but if you hadn't given me the right direction, I'm almost positive I would have done very nasty things to my code without knowing any better.
and hide item slot you clicked temporarily until drag is completed (and unhide if operation did not swap)
yeah no problem. Inventory stuff is a pain
|| is OR operation, while | is bitwise OR
ye, I almost had a panic attack when a minor bug cropped up, I was so wound up trying to make the inventory system work, lmao. It turned out to be the simplest thing to fix, too.
Basically, my current system has icons, but it also has empty slot gameobjects, and the icons slide towards the "slot" they belong in. I was deleting the empty slots when they were no longer needed, which was causing bugs when trying to use certain functions, since item icons would get confused which slot they were meant to be "assigned to"
Thanks
It's useful for combining layer masks for raycast operations and such
Now, my inventory currently only creates empty slots, without ever deleting them, so the "array" of empty slots is always equal to the highest number of items to have been in the inventory so far, preventing issues where there are too many icons and not enough slots to assign them to.
I might do something more optimized later, but I'm goingto hold off on it until it becomes a problem.

