#💻┃code-beginner
1 messages · Page 492 of 1
can u give exemple ?
u mean the dug.log?
thats what debugging is
well not specific to Debug.log but it is a big area
debugging also expands to errors and warnings and knowing what they are telling you
and common sense
click on collapse in the console please
when i press jump the on jump turn pressjump to true
doesnt reach Debug.Log("double jump");
i dont think it the problem ive change the handlejump function multibles time but be cuz it called from update something is happening so fast that it dont let me count double jump or it does cout double jump but wont preform it cuz its happening so fast
`private void OnCollisionEnter(Collision collision)
{
grounded = true;
doubleJump = false; // Reset the ability to double jump
Debug.Log("grounded true");
}
private void OnCollisionExit(Collision collision)
{
grounded = false;
Debug.Log("grounded false");
}
void handleJump()
{
Debug.Log("entered handleJUMP");
if (isJumpPressed)
{
if (grounded)
{
Debug.Log("grounded jump");
rb.AddRelativeForce(Vector3.up * 10);
doubleJump = true; // Allow double jump after leaving the ground
}
else if (doubleJump) // This will only trigger if grounded is false and doubleJump is true
{
Debug.Log("double jump");
rb.AddRelativeForce(Vector3.up * 10);
doubleJump = false; // Disable further double jumps until grounded
}
}
}`
void Update() { //AnimatorStateInfo animStateInfo = animator.GetCurrentAnimatorStateInfo(0); //moveDirection = currentMovementInput; handleRotation(); handleJump(); } void onJump(InputAction.CallbackContext context) { isJumpPressed = context.ReadValueAsButton(); //if jump press true Debug.Log("Onjump"); }
okay first off, please format your !code correctly
📃 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.
is your debug for DoubleJump being called?
from what im seeing, it looks like fine code other than you applying addforce in update()
"double jump" yea
what do u mean ?
you are suppose to apply any physics things in FixedUpdate() due to the fact FixedUpdate() is in the physics update of unity and its framrate independant
while Update() is framerate dependant, so the lower the framrate the slower you go, vice versa for the faster your framerate is
show us whats happening when you double jump, it should be adding a force to your rigidbody
Hm, im writting my own "Makeshift" Inventory, when i want to destory an object of a child component, it said im not permitted to destroy it because of data-loss what should i do instead? Replace it with a placeholder?
what are you destroying
a gameobject
do u want an public for somthing to see the check box ?
maybe i should use scriptable objects instead (technically still gameobjects)
or this is fine ?
and is it an actual instance of a game object or is it a prefab from the assets?
a video would be preferred
so we can see what it actually does
Its a prefab currently
so are you destroying the actual prefab itself instead of an instance of the prefab?
Ah this makes more sense
yeah, if your destroying the prefab itself thats why there would be "data loss" because you would be getting rid of the prefab completely.
but if you destryo an instance of it that would work fine
Hm, can i make instances in the editor? Or only with something like a spawner
an instance would be something you Instantiate(prefab) into the scene
not sure what you are exactly trying to do if you want instances in the editor?
that doesnt really make sense
an inventory realistically is just a list of items
Yeah im just trying my functions and working on drag & drop
so i put something into my array
and want to drag it out, but i did put the prefab in it with the editor which is not an instance
does this help ?
sorry i was doing something, your code is working exactly how you told it to. your problem is that its activating all at once.
you can either use a coroutine or invoke it to make it stagger or preferably see if you pressed jump in a short amount of time then execute it
How can I debug through my TestRunner code? It won't find my breakpoints in my tester file:
actually seems to be most the files
whats wrong with my breakpoints 😭
why is it that if i set the body velocity outside the wallJumpCooldown block, the jump animation that pushes the sprite along the x axis no longer works (body.velocity = new Vector2(-Mathf.Sign(transform.localScale.x) * 10, 2);)
it only works if the i set the body velocity within the wallJumpCooldown block:
!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.
Bit about large code blocks. 😕
is there any difference between setting the body velocity at the start of the awake method and inside the cooldown block?
ok i think i've got it, it's because of the delay introduce by the cooldown block. for anyone else with the same issue at this moment in time, if you don't have a delay between frames, your velocity movement will be interrupted and replaced by the next velocity line as soon as the next frame loads.
by putting it inside the cooldown block, i gave myself about 12 frames for the jump movement to finish before taking back control.
Is it usual practice to put camera as player's child or to put it as independent object and then provide it to the player using SerializeddField? I've tried to have it as a child to my player object but I had a lot of problems with it's rotation and tried to move it out of player's hierarchy, which made it suddenly work, but I don't understand why my approach wasn't able to produce correct result. Relative rotation was a big problem for me. I wanted my camera to face the player while player is rotating (he is rotating as he is moving - he is facing direction in which he is moving). During that time, camera is keeping same offset from player (which is it's parent) and is looking at the player the whole time. Since camera was child of player, in order for it to keep looking at the same position, I had to apply invers of rotation that player was getting rotated for. I also wanted to be able to manually rotate my camera. Once camera is rotated, I wanted my player to move in the direction that camera is pointing to. Now what I had to do, is to apply rotation to the player which is equal to accumulated_offset_rotation (which represents all the inverse rotations that had to be applied to camera in order for it to look at the same point) * current rotation of the camera. I still don't get why is this approach wrong. If somebody got any suggestion on how to make camera work while still being child of a player, I would appreciate insight and ideas
depends on the type of camera wanted
if its child object it will move and rotate with the player, that is often not wanted if its third person camera. where you often want some sort of easing and damping on its movement
Yeah that makes sense. So it would make more sense to have it as a child in case of making 1st person camera right?
yeah for a first person i would make it a child object
since you really want that directly tied to player faceing which is directlyed tied to mouse input
I am making 3rd person camera, and as you have said, moving and rotating of camera with the player isn't wanted because it can result in lot of these edge cases and can cause a lot of tweaking to get the result. I am just bumped out because I wasn't able to find out what was I doing wrong even though relative rotation as a concept seems pretty straight forward
That makes sense thank you!
yeah for a 3rd person i would just make it its own object and give it reference ot the player so it knows how it track
would use something like cinemachine, or do some basic vector math and compute a position and rotation relative to the player
also other reason to have it its own object is most games let you have some camera control indedepent of player movement with right stick or mouse
I considered using cinemachine but I haven't looked too deeply into it. I needed pretty basic functionality that might be upgraded and expanded further down the line, so I wrote my own camera class because I wasn't sure how flexible is cinemachine
its fairly flexialbe, but wrting your own is also good experience
Yes, I am doing the same thing haha. It makes sense now to have it as separate object
cinemachine is a good solution even for a 1st peson camera..
vcam being the child
I agree, you can't go wrong with it. You can add all of your requirements in it
and the main camera is just loose in the hierarchy
for simple cases computing the position should be easy
just cameras take a lot of fine tuning
I'll definitely have to look into it as soon as possible because I've seen that everybody is using it. It must be really good
you can still write ur own camera code and use a cinemachine.. thats how i do it..
(the camera code just rotates an empty gameobject) the cinemachine cam is just nested to that object
yeah i have done all of hte above, pure scripted camera, cinemachine, or having the cinemaching camera follow a camera target i compute
I haven't thought of that tbh. That seems like a good idea haha
that way its easy to transition to cutscenes or Points of Interest etc..
Which way is the best in your opinion? Or does it depend on the context
i just enable another cinemachine camera with a higher priority
and then it takes care of the transition for me
done and done 🙂
depends on context
but yeah spawn camps point about cutscenes is useful
Oh I am miles away from the cutscenes haha. I am just getting into gamedev
ya. just throwing it out there 👍
cinemachine pairs very well with timeline if you want to have little in game directed bits where camera gets taken control of
always good to think a bit ahead
the blending between virtual camers is great
I agree, I will think of this as I get there someday. Will need to dig less on the internet 🙂
and the dolly camera's and what not are very nice for hand made camera movements in cutscenes
what are dolly camera's
lets you define a spline that the camera follows along
the main take-a-way is.. cinemachine handles everything for you..
disable and enable cameras.. and ur gold..
the one w/ the highest priority will become ur main camera
Oooh that't nice. It sounds a lot more interesting than just linear paths
Although splines can be pretty complex, I don't know how does unity handle them
its good for cutscenes, but can also be used on gameplay cameras if you want the camera to follow player along a limited path. think like resident evil fixed camera angles but the camera can move a little to follow the player
Oh I get it now. This really makes things easier
I can't excatly visualize how would a spline be good in that situation. Isn't it more natural to have linear movement of the camera while following a player during gameplay
also its really nice for framing of things, expecially in 3rd person games where you dont want the player right in the middle of the screen
Dolly
Unity has its own spline system now doesn't it?
im guessing thats what cinemachine is using
yeah really just a curve follow, they just call it dolly to use real film terms
im 💯 okay with that..
i try to use Film terms as well
hence why i call it CameraRig
fine with it too, before games i was doing audio and film stuff
same lol.. i used to make stop-motion films on a VHS recorder
yeah some local docs, government ads and a bit of post production work cleaning up audio for some movies
ohh thats cool
i despise editing.. more power to ya 💪
yeah doing that type of post production is pretty boring, its like 90% adding back in missing sounds based on context and fixing pops and bad mouth sounds in vocals
music production was much more fun but still pretty tedious
lmao the last part of that sentence is the WOORST
i ahve this nice setup and i still have to edit almost all my vocals
yeah still really have to fix all the sibilant sounds by hand
also sometimes i will just make things flow better and changing the timing a little
Good afternoon, How is everyone doing this fine Sunday afternoon? I am having a heck of a time trying to get my game over screen to pop and disable movement or the renederer for the player. It seems in the list of actions only a few get done and/or it just does not run them. I also do not get any errors. So that make me think it is running just not as I intended. In gameOver, it will disable the CarSpawner and the cars stop spawning. It sets the gameOverScreen as active. It also logs the Game Over! What it does not do that I can tell is disabling the player input or the renderers. If I uncomment out any of the lines, the ones below won't run or don't show up in the screen. If I move the commented lines to the bottom. Everything works except for the disabling of the player input or the renderer. Would anyone be able to point me in the right direction?
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
good to know its pretty common tbh
debug the GetComponents to make sure they're grabbing a Renderer
also.. show us the Disable() function..
So, I found out why I was not getting an error. I had them turned off in the console. For the renderers, I get the error, Object reference not set to an instance of an object. For the disable, I was just trying to use the same code in my player controller. It just says:
'''cs
private void OnDisable()
{
move.Disable();
}
'''
I get this for the renderer debug. It still does not disable it. So I looked at my prefabs and it is turned off in there. Just not the ones on the screen.
do u know of any good video for joystick movement like if you push the stick a bit it will walk and if you push it all the way it will run ?
You can get a Vector2 back from your joystick input, the length of that vector will already be greater or smaller depending on if the stick is pushed alot in a direction or just a little
can scale up that vector to use it directly, or you can use the length of the vector and a curve to choose how fast you want for any given vector length
is there a code i can look at ? im kinda confused by all of that
im using the new inputs
btw
hi, does anyone know how to disable and enable emmision of material but with code
the input system provides everything you need, so when you get an input from the input system by using Vertical or Horizontal it will give you the output of X or Y which you can compare to see if its greater than a threshold set
with new input system no real need to do Vertical and Horizontal on there own, the binding can return a Vector2 directly
but yeah i don't really know a guide or anything, but sure the docs can show how to get that information and do basic input
i mean if it just give you a vector2 you can just compare a value from it to whatever threshold you set
the most basic case is just multiplying that vector from input by your speed, and it will scale it smaller if you push the stick only a little
though to get more control, i will do speed and directions independently, so will first get speed by taking the vector length and using that with a animation curve to remap the number to what ever i want
then will multiply that by my normalized vector
but im not sure why they wouldnt make running togglable 🤔
or just make it a setting for either or
most games still let you walk slower with less stick push
is it called axis deadzone in the new input ?
with run being its own modifer on top
no its not, axis dead zone just defines how much the stick has to move to do anything
no need for a processor
just make the type 2d vector
then when you read it with read value do ReadValue<Vector2>()
nono i know that, but for example minecraft lets you push the stick in and it will go to running
do i need to make a new run input in the input acction asset ?
you can if you want it togglable but dont use a vector2 for it if thats what you want
nah would want it for move
but like passerby said, use the joystick inputs and multiply by some arbitrary float to get desired speed
really just google stick movement unity input system or search it on youtube
sure that will give a starting point
ty both @shell sorrel @steep rose ill try it
would just get things working first, then after that can build on it to get the correct speed for the vector length on the stick
Is there some way to tell in the editor what the "true dimensions" in unity units an object is? I know in code you can do something like check the bounds, but I just want to be able to check at a quick glance
Not really, and it's not exactly clear what you are interested in. Presumably the size of the Renderer bounds?
Renderer bounds yeah, though with the objects I'm using they are more or less equivalent to the collider
yeah assuming you just want its bounding box, could get that in a editor script and display it
Nothing built in but it wouldn't be that complicated to write an editor script for it
How does one make an "editor script?" Is it like a static class or something?
using UnityEditor;
can define a custom window/panel you can dock that will show you the extra information you want
can have it just follow what the selection is
yeah unity is very customizable, you can create new windows like this, toss custom stuff in its menus as you want
opinions on an in-line if statement if (!entity.target.targetPathing.enabled) { this.target.targetPathing.enabled = true; }
Just remove the braces if it's a single line?
How do I check the current selection? Atm, I have what the doc example has
Oh, nvm there's thankfully a built in class for selections
if the goal is for others to not want to read your code, then success. you arent printing this out on paper, you dont need to save lines.
Single-line if statements are common. No need for the braces . . .
trying to learn inventory systems and scriptable objects are coming back up
i checked with the official unity account and to clarify: the data they store will persist throughout different scenes right?
on what you mean. scriptable objects (SO) are meant to be used as immutable data containers. you give it data, and then dont change it at runtime. Read and copy the data to your own instance.
During a build, if a scriptable object gets unloaded, i believe itll reset back to its original data
THere are many different kinds of editor scripts:
- Custom inspectors
- Property Drawers
- Custom tools
- Custom windows
Editor tools would be the best for this in my opinion:
https://docs.unity3d.com/Manual/UsingCustomEditorTools.html
trying to figure out how to do an inventory system with the proper ui has been beating my ass
im trying to understand what all the code is doing and why, so i just keep stopping the videos to try to learn about all the functions they use and its rough
i gotta get it done regardless ig
why scriptable object
why not mono behavior
why not a custom class
thats because everyone has their own system to make inventory since its such a complex system usually, you're simply copying someone else's way its not necessarily the best method
🤷♂️ i cant really suggest much based on what you're saying. if you have a specific issue then share that
just some general advice, first work on the inventory without UI. UI is just gonna be used to interact with your existing inventory. An inventory is just a list of objects. A scriptable object would be used here purely just to provide your objects with data. You can read and forget about the scriptable object immediately
100% make a simple inventory on your own, start with simple collections and def without UI at first
okay we'll just sideline the UI for a bit then
i feel like i kind of have ideas of how it would work but id have to try
ill return in 2 days and if i dont have the basics down then im going to accept defeat and the player will just have to move everything one by one
How can I run my DisplaySelectionInformation function the moment there's a new selection? Right now, it seems I have to mouse over the window for it to run.
My class as of right now:
https://pastebin.com/mtgeSKhW
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Ah, the good old Repaint function. I remember this from school lol
i have a method similar to this
its for drawing icons.. but anytime the editor repaints the icons get updated
Right, I forgot about that lol
Hi, I have a main menu on unity and would want to know how to make it to play the game when “play” is pressed
K Ty! I’ll look at this
I downloaded this one, I’m new to scripting so idk what and where to do. I tried understanding this too
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
these will show you how to setup a proper IDE, which will help you alot while writing code
That’s how I edit scripts??
Okay, idk how to use that
what the bot posts shows how to setup a proper IDE, unity install visual studio for you
Read a tutorial how to use VS Code, you will thank us for that
that is kinda horrible lol
How is it horrible?
too many reasons to list, formatting issues, no syntax error highlighting, no intellisense etc. etc
- No Code formatting
- No highlighting
- No error display
- No auto completion
- No Unity integration
!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
Oh. Okay
when you installed unity did you let it install VS for you?
Free: VS Code
Free with more power but imo not needed: Visual studio
Paid: Rider
chances are if you installed unity via hub you prb already have VS installed
VS is preferred
VS has been an absolute shitshow for me lately for some reason, just crashing constantly
yeah for a beginner just use the VS that unity installs with its self
what why?
corrupt install?
I wish i knew..the latest updates.. me think so
Can someone tell me what to do here, like where to make it so it can load the game?
reinstall it maybe
it crashes usually when have multiple ones open with unity. which was never the case
use a IDE
please
you are not going to get very far without using a proper ide or code editor and learning some basics
year Ill probably try that later, i have over 20GB of VS workloads installed 
would focus on those 2 things first
20GB is crazy, best of luck 😂
yeah .NET MAUI alone was like 8GB or some shit.
and All the Windows 10/11 SDKs are beefy
making me glad i just use Rider and really dont touch any windows .net stuff
yeah much better now doing .net core because its multi platform
fuck the windows sdk and UWP tbh
Why are y’all so worried about me using notepad for, it’s what I use to open scripts.
Just tell me what to do so I can do it
because you need a proper and configured IDE to even get help here
you with your rider IDE, i should use it prob
rider for the win
because it makes things literally 100x harder provides you no support, provides no error messages
im guessing its nearly/roughly the same as VS?
also otherwise you will just come back with some issue related to syntax or other simple to avoid issue with a configured ide
also sounds like you just want people to do the work for you, this place is not about that
Faster, better UI, but usage wise yes, you can even use the VS keymap
better be for that pricetag 
Okay I’ll install whatever you want me to install , what is it?
well when VS eats my PC ill switch lmao
it probably will soon, these load times are nuts 
!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.
VSC is faster
Please ues a paste site 😄
myb
really VSC is faster?
well yeah its basically a text editor with extensions, its very light weight
What is it?
you've been linked to the instructions
can someone help me? im trying to figure out why im getting this error...
Assets\movement.cs(39,19): error CS1061: 'WheelCollider' does not contain a definition for 'breakTorque' and no accessible extension method 'breakTorque' accepting a first argument of type 'WheelCollider' could be found (are you missing a using directive or an assembly reference?)
https://hatebin.com/fjadbjrgqy
its brakeTorque
you made a typo
fix your typo
check your system , again if you installed unity via hub chances are you already have VS installed
make sure you have a configurd IDE to avoid such mistakes 😛
the error message clearly shows you why, but also your autocomplete should have only gave you the correct one
wdym? its even the all product pack, I'd hate to be a professional 3d modeller and have to pay maya or some autodesk stuff 😄
how do i add the autocomplete stuff for unity?
K thanks
!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
How do I download this?
try being a Videographer / Editor .
Using Adobe its bleeding me dry lol
yeah been using the all products packt for like a decade, i find the pricing is fine
The high seas are calling 😄 no but seriously, i hate adobe, charged me 150 bucks just to cancel my sub early
like when i was doing tech art as a contractor and needed my own maya that was miserable
Idk how to download it, “🤔” dosnt help.
yeah its fucking criminal. Thats mainly why I dont support any company that uses monthly subs. you never own your own purchase it sickening
still have adobe stuff on my work machine, but for home i cancleded it and went with the affinity stuff
it is not something to download
you were linked a guide 5 times now
are you like a troll
you've been linked to the proper things many times
hehe just use gimp
that might be worse
Not at all no
gimp (i still use it over PS at times and I own PS lol ) doesn't even come close to PS and also I need something in comparison to After Effects/Premiere.
Tried Davinci and alike, they're ok but not as good
thanks
wdym gimp is free
Affinity for images, davinci for video right?
i have no need for video editing right now so not looked into it
well ofc for a free software it wont have every bell and whistle possible but at least your wallet is not bleeding
but the 3 affinty tools are great for the price
I don’t know what this is.
that was not even for you
i dont mind subs if the policy around it is ok (jetbrains gives you a perpetual licence for the last version they published while the sub was active)
and the 2 times something wasnt working in rider / webstorm they responded in <24h and fixed it in a week
i feel this model is a good mid ground, it still encourges them to innovate otherwise i sit on my last version
yeah thats a better compromise that most wont do, i still don't see anyone else doing that
its because they are software dev company they probably know the pain, but still monthly pricing for a product is still scummy practices imo 🤷♂️
even out of free ones its just bad
krita would be better
krita or gimp, both are good
no gimp just bad
if i had to use it i would charge more
Oh
I think I need one person to DM me about it, I think it would be easier for me
no one will DM you
just follow what we said
just watcha youtube video or something
and you will be fine
!ide use the VS installed from unity hub
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
if setting up an ide is this complex to you, making a game wont be any easier
What’s a VS??? I’m so sorry I’m just so confused
everything about making a game, will be about problem solving, and breaking problems down
Visual Studio
VS = visual studio
google anything you don't know
Visual studio can that be downloaded?
yes
Okay, thank you, I’ll download it now
check your system you might have already installed it via unity hub
what
I don’t think so now
how
Obviously not
you were linked a guide so many times
Yes, "clion" is actually "visual studio", same letters, letter by letter
you trolling?
No!
it shows you everything needed, where to get things and how to configure
I have a disability and I’m trying very hard to understand.
Please stop putting that emoji, I’m not trolling at all, I don’t have a reason to troll.
Thank you.
Anyways I installed it
no need to show us this, follow the steps and get it done
follow the installer instuctions
Okay.
then once installed come back and we will lead you to what you need for unity
Oh lord I gotta find it again
Hold on
Forgot where the instructions are
scroll up then
you can ALT + TAB to find the panel again
quit being a child
if VS is installed click on this link #💻┃code-beginner message
and follow the instuctions and you should be good
So THATS the instructions right?
thank you.
Start with number 1. work your way through steps until "Check for updates" section
Reminder that step 3 is important and something that you'll need to select on your own during the installation.
Why not just tell me what to do with the main menu part?? That would’ve been much easier
also the message with setup instructions lets people choose the option that applies to them most
you have to do it yourself, we could do it for you and configure it how we like it but that may be not how you like it, not to mention you need to learn how to do this
does the ternary operator ? work with booleans? like
boolean ? //dosomething : //dosomethingelse?
correct
in fact it only works with booleans
var value = condition ? ifTrueValue : ifFalseValue;
hm, alrighty thanks guys 👍
both branches of it must be the same type
Hi trying to learn the code for basic movements, could anyone help me with a wiki or a code? thx!
wdym "a wiki"
"basic movements" is not really meaningful without explaining what kind of movement you're trying to achieve.
Look up a tutorial for the kind of movement you want.
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
thx dont really know what im doing, for context just a 3d game with w a s d and jump
though im trying not to watch tutorials
tutorials don't only consist of videos
oki thanks!
Could someone give me some help?
I'm trying to make the delivery script
I'm using mouse click to move
I am currently suffering from some problems;
My player (any block) keeps flickering the base of the map
and if I hold and drag the mouse, instead of it stopping in the place I clicked and/or held, the block slides to wherever it wants
NOTE: you can't see the pointer
You would have to share your code if you want help with your code.
As long as you share it properly !code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
you are in a code channel
📃 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.
please follow the bot you just provided
You're moving your dynamic Rigidbody directly via its Transform
This is a problem
and it explains your shaking player.
You have to move Rigidbodies via the Rigidbody.
also just note if you plan on using walls and navigation, you should probably use navmesh instead of Vector3.MoveTowards. Or you can still use rigidbody just pass it the waypoints from navmesh
Not only that but the position you're moving it into is presumably inside the floor since you're directly doing target = hit.point; where the raycast hit the ground
hence the violent shaking into/out of the ground
Presumably your player's pivot is in the center of the capsule
I understood, but I wouldn't know how to apply this in the code
probably easier to just use a navmesh then do SamplePosition with the hit.point
https://docs.unity3d.com/Packages/com.unity.ai.navigation@2.0/manual/NavMoveToClickPoint.html
or use maybe offset / plane ?
is there really no way to read this property of Rigidbody from script? i cant use velocity cuz thats a Vector3, this is pretty much exactly what i need since im trying to see if the speed is higher than a constant
but rigidbody.speed doesnt exist
thats probably just the magnitude
rigidbody.velocity.magnitude
I'm taking a while to respond, because I'm trying to apply what you're saying
I'm using Google Translate to read what you're saying xD
which one ?
how would i find the closest transform to another transform in an array? would i use a for loop?
linq maybe or write your own Icomparer class (using Array.Sort method)
or good old fashion loops lol
wrote this yesterday to get closest target for autoaim, might be handy. Lets you just use Array.Sort
https://hatebin.com/luuiaclksj
then you do
var compare = new DistanceComparer(transform);
Array.Sort(closestTransforms, compare);```
How come when i give my object a new script the script program opens and its just a blank page? How come it isnt the normal page with the bacis lines it gives you like unity engine and mono behavior
unconfigured IDE maybe?
screenshot
of the script page or?
yeah , whatever opens
and you're double clicking script from unity?
yea
can you screenshot rq Preferences in Edit -> Preferences -> External Tools page
for refrence i created a folder and then put the script in the folder then dragged it into the player asset
I would probably not use a rigidbody/collider for this at all
I would probably do like a CircleCast each FixedUpdate from the paddle's previous position to its current position
I would code in directions using vector3.reflect and such methods instead of triggers
close VS try clicking Regen Project files then open script again
if its still blank open up solution explorer window view in VS
idk if this helps but it seems to show up on the right side just not when i open it
yes but its the script file isnt opening at all
so there is a disconnect happening somewhere
ok
I don't have much experience, could you explain me what I should do? I heard about CircleCasts some time ago but I don't know how to use them.
Same about navarone's idea, I don't have much idea how to apply it.
i think i found it, the script is in my player asset under sample scenses (the compontent is in there) though in the asset section the player doesnt have the compenent
look it up and look at examples
for mine was basically just suggesting, to instead of calculate the bounce directions via rigidbody bounce (I find this to have less control for me esp with how unpredictable physics material bounce is)
I opt in for using methods such as Vector3.Reflect and use casts, like a spherecast/circle for example to bounce off colliders and get the point for my reflect. I'm not expert though because I still get the sweats with trig math 😅
https://docs.unity3d.com/ScriptReference/Vector3.Reflect.html
(so far only done for games like Pong, Breakout etc..) got much more control and precise results including adding specific "angled hits"
Okay, I think I managed to solve it...
https://gdl.space/ulosuyalih.cs
Now, I need to solve the problem of it sliding when I hold and drag the click...
you mean the ai code ?
Yes,
This is code using the 'character controller', I applied gravity and with that I adjusted the ''tremors'' that were giving
and the problem was Rigidbody
yes but now with AI code you know 0 of how any of it is working..
also " problem of it sliding sliding" is very vague
yes, I'm using GPT to adjust the code, I'm ''doing'' this in Python and passing my code to GPT to change
hi, is there a way to know if an animation has been completed?
that is horrid mate, why not just learn C# and do it properly so you know what you're doing.. The "AI" isn't a thinking machine and it wont know how to solve things unless its something very obvious you could've noticed yourself.
slip into question
isnt Animator just a FSM just use the StateExit function in code?
or what i do is just use Animtion Events and call it a day (this is diffcult if you have many transitions)🤷♂️
Yes, I could have noticed, but I didn't read the documentation to see the functionality, I've been messing around with Unity for about 10 hours, so I'm just going for pure entertainment
i need help inporting a map
help will likely be hit or miss Mattheus, its like someone that was once a professional lego builder building a house out of timber, it falling on someone then him asking help from a carpenter to make his job easier by helping repair the fallen house and paying the insurance claims foor freeee lol
not a code question
why not just learn c# out-right
great example xD
I have good programming logic, I really didn't want to waste my weekend studying, but rather thinking and getting frustrated, that's what I like about programming
if you plan on making a game in unity you should lean c# period
then that just means ur 1 step closer than the average beginner would be to learning how to code in c#
anything you're doing in the ai wont get you very far at all without that base knowledge
actually ur even closer.. b/c u know basic programming and structure
C# is easier than python
i would agree
My didactic way of learning is a little exotic
ur just using a translator to copy and paste stuff
whatever you're doing now clearly ain't working chico lol
I already work in the technology area, but I am a data engineer
but i guess its still a form of learning.. if u take that gibberish.. try to use it, realize it doesnt work.. and then end up fixing it
then u by definition have to be learning
that is if youre fixing it
that explains python 
lol fr
literally for data science
yes xD
ud be great at making inventories and stuff
i hate python, one space fk everything
GOAP or is it Utility ?
I understand what you are talking about and it is justified
i once wrote a discord bot.. now i'll never touch the stuff again
mmaybe for machine learning..
I like python, I've done several atrocities on it
Russian roulette to delete the system32 folder
what are we lookin at tho?
keeps sliding infinitely, But that's enough for today, I work tomorrow and I drank a little today
looks like how a rigidbody might act.. and the forces just doing their thing..
once u do the lil circle manuevr it has force sent out diagonally.. and just keeps taking u that way
then ur normal inputs clash over that to get normal movement + that odd diagonal
having, now I'm going to sleep, thank you very much for the conversation and the help ❤️ ❤️
Tomorrow night I will try to solve this problem
''problem'', physics is not a problem xD
uh heya quick question! what kinda variable would i use if i wanted to store multiple values? i'm trying to make a leveling system and i need to have different values stored for each level (exp til next level, defense increase, str increase, ability to gain, etc) and i was wondering if there was some sorta variable i'd use for that or if it's better to just make a class with one object per level for it or something like that
A class/struct.
okay thank u
You kinda answered your own question lol
i mean yeah i was only really asking because idk what would perform better
idrk
i'm not that good of a coder lol
between what options?
Why are you worried about performance here?
lemme rephrase that, i don't really know how classes work but i assume since i'm creating lots of objects they'd take up space in memory or storage
Yes, data takes up memory
that's how it works
that's what memory is for, to store data.
yeah fair
how do you check which classes inherits your base class quickly among many references ?
There's no getting around that. If you want to store information, it takes up space. This isn't a problem.
Use your IDE tools
In VS I think it's called "find all implementations" or something like that.
i got it, for visual studio, in solution explorer you expand the class file, then right click on your class item. then select "derived types"
okay i kinda got it right?
i can add things to the list
problem is that im not sure how to make it just add it once, and then destroy the object, but also not destroy the reference in the proces
trying to find the hastebin link
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Are you trying to make an inventory system or something?
yes
What do you want to do with the objects you add to your inventory?
I don't understand
well the end goal is to have the objects be represented in an item slot, but for now im just trying to figure out how to add things to lists
currently im not even sure im going in the right direction here, because while the thing does get added to the list, im not sure how i control quantities
or how i will have it be represented in the slots
Can i see your code for inventory?
InventoryManager:
https://hastebin.com/share/ruvavijahe.csharp
PlayerInteract:
https://hastebin.com/share/gibigixefe.csharp
player interact is kinda big so the only important lines are 28, 72, and 116
originally right under line 72 i just had it destroy the game object it hit, but doing that removed the reference, and now im just kinda stuck
Do the items get added more than once? is that the issue?
will record
when i change it to destroy the item, the list updates, and then goes "Oop well you destroyed the item so no more reference"
leaving it so it doesnt destroy it doesnt really cause a problem. it lets me infinitely click it, but i kind of need to have the item slots organize it properly
I can show you how i have my inventory pickup done if you want
im just not sure what im doing tbh
i can add it to the list but im not sure how im supposed to remove it but also store its data
that would be appreciated, thank you
this is rough ;-;
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
this is my pickup method
hopefully the comments added make sense to you
Well, if you still need the item to exist, then don't destroy it.
I think the issue is that you're not differentiating between items and their physicsl manifestation in the game world
i dont understand 
im going to try to start over
not the entire thing but just the part where im asking it to add an item
- Press E,
- Shoot raycast
- assign obj to the object that the raycast hit
- get the colliders and the rigidbody
- turn off the colliders and make the rigidbody kinematic
- set parent to my hand object, local location to 0,0,0 and rotation to 0,0,0
- Just realise that i left out the part where i add the item to the list
wait, no i didn't lol
Can i DM you?
@marble hemlock
Hello, this is one of my first times coding and Im watching a tutorial to help me get started. It was going good but I ran into a issue of then I did public GameObject pipe; the game object would not show up in my inspector.
cs
//
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PipeSpawnScript : MonoBehaviour
{
public GameObject pipe;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
Instantiate(pipe, tansform.position, transform.rotaion);
}
}
tansform.position is this typo or is it actually wrong
It was a typo
pipespawnscript already attached to gameobject in inspector ?
I think so
no error at all ?
!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
you typo on rotaion too ?, fix your IDE first
double check your spelling errors
I just looked at IDE and it is up to date
you don't even have your console window open
you clearly have a compile error
open your console
and configure your IDE
tansform.position and transform.rotaion
up to date doesn't mean configured
Ok Ill make sure
Im showing you what a configured IDE looks like, fixing typo now wont help you for future syntax / spelling issues without configured IDE
I changed some code on one of my other scripts
problem solved then ?
Ok Ill make sure my IDE is configured
Yea thank you
now i want to know, what tutorial instantiating in update. can you link the video ?
I hope there's a timer that controls that instantiation, yeah
yeah def missing a timer or something
🔴 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...
Yea I think we are going to add one because he does some things wrong to show what happens then goes back and changes it
actually you havent finished that part, he does it and then adds timer
yea
its always good to watch a video like this a few times before copying the code
its easier to learn what video is about without code at same time
Im at 22:30 so I have a ways to go
Ok
reflect wouldnt replace triggers thats what casts would do
reflect just to give the ball more precise control idk how precise you need the paddle hit
could anyone help me figure out why im not getting any collision detection from my enemy and bullets when the enemy has a rigidbody component attached to it, compared to when the enemy doesnt have the component attached to it and i do get detection, this is the case for both projectile/rigidbody based bullets and raycast weapons
https://unity.huh.how/physics-messages
this link has a ton of reasons for why u might not be getting a physics message
Hey, can anyone give me a hand here?
I have two transformer handles using MetaXR All-in-one SDK through the One Grab Translate Transformer
Problem is
when i switch between the X and Z axis, the parent transform resets, if i move it in a single axis it works fine
if anyone's interested, this is what the OneGrab translate transformer looks like
Alright I need some help, I've been trying to make this setup work where we can set a Target RPM, Voltage, Max Torque and Max Current as well as a Load Torque and simulate how the motor will work as in how much torque and current it will need to spin the gear at the target RPM and whether it will reach the Target RPM before hitting Max Torque or Max Current or not.
I have attached the Pair of Scripts below (they are AI Generated because I cannot figure this out for the life of me) which control the Roatation of the Gears and govern the system.
Trying to learn/use coroutines. I started a coroutine that has a "yield return new WaitForSeconds(5f);" inside of it, then after the coroutine I did a debug.log to see if it was delayed, but the debug.log happens instantly.
Does Unity not wait for that coroutine to finish before executing the next line(s)?
I AWAKE
ive decided to completely sideline the inventory system
the solution to one's problems is to pretend they dont exist until i inevitably have to circle back around to it
https://docs.unity3d.com/Manual/Coroutines.html
no the function does not wait for the coroutine to finish. this would pause your whole game if it did
!code
Nope, it doesnt wait for the coroutine. If you need to wait for a coroutine inside another coroutine, you do yield return StartCoroutine(...)
📃 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.
Gear.cs: https://gdl.space/apelikisup.cs
GearSystem.cs: https://gdl.space/ohukafifel.cpp
did that
This problem has been stumping me for the better part of a week

Would this be a reasonable way to handle something?
Idea is they press a key, all control is disabled, then it starts a chain of events with like 2s~ delay between each. 5 or so events later, they're allowed control again
did I do something wrong?
Sounds like a reasonable use of coroutines. Either that or manually keep track of the timers and counts in update
Not you
ah ok my bad
Me, i'm losing hair over my issue there
same
at this time I am cursing every single individual who encouraged me to take up CompSci
there really is a lot of code to go through here, and it doesnt really look like you wrote what the problem was tbh. though i just noticed you said it was AI generated. you'll probably not get help with that here. Start debugging and try to find what the actual issue is. go through the values yourself and see which dont line up
also i don't currently trust AI with math very much
If I were to start over, what approach should I take for the same Objective
that being to Simulate a Motor and a Load
break the problems down. i never really studied much physics so i cant be of much help for the actual equations. Id first start by getting the equations down on paper, then in code.
plug in some values, and debug what the results you get in code are. check if those results are correct for every line
well I do have the Physics part sorted out, the problem is having that physics work with Unity.
I have never used unity ever in my life
if you're familiar with coding, even outside unity, this really shouldnt be hard to debug for what line is going wrong. Knowing why its going wrong may be unity specific if you didnt make an error in the equation
Morning all,
So, I'm experimenting with MoreMountains Feel to control the steering of a vehicle, and so far it's working great (does exactly what I need it to do), but now I'm trying to apply the Y rotation value (That Feel assigns) of a SteeringController Empty to the .steerAngle of my WheelCollider, but as you can see from the image, the rotation.y value is very different (the steeringController empty is set to have a rotation.y value of 15 when the logs were triggered).
Is there some kind of conversion I need to do to get an accurate value?
you should also debug to see roughly where the error lies. It somewhat is a pain to read this code and you should be able to narrow down what part isnt working.
not many people are gonna go through all this code to understand whats happening
Alright, Rephrased Question. What is the easiest way to make thing A spin thing B
just throw all the physics out right now
a hinge joint will only spin thing a
unity stores rotations are quaternions. 15 is not a valid number for a quaternion component
I want the thing b to be spun by thing a
Yeah I thought that too. I did try grabbing the localeulerangles value too (I may be misunderstanding how that works though I will admit) and it came out with the same value.
So I guess I need to convert the quaternion to a radian?
🤷♂️ it depends heavily on what you're actually doing. if you want something decently accurate to the real world, which seemed to be case above, you arent using anything related to unity physics here in an easy way.
directly changing the rotation is gonna be the easiest way
i dont know what you're trying to do so i dont know how id answer that. it sounds like you just want to construct a quaternion using Quaternion.Euler. Im not sure where you want to apply radians here
I only want the Visuals to be Semi-Accurate, the real data is in form of Text, that being the Heat generated, the Current Draw etc.
The Gears must only Spin, slow down when Load is too high and so forth
I think the Script I am using has become so Bloated it's practically unusable
So I want to make a script add a string to a list of strings in another gameobject
if you're already generating the real data, then you might as well just update the game objects with the real rotations
unity physics might be a pain in the ass for stuff like gears spinning.
Sorry, the radian thing was a 'misthinking' lol.
Okay, so the wheelsteering controller empty object rotates to 15 degrees, so I need to grab that 15 degrees and apply it to the steerAngle of the wheelCollider.
When the object is added to your cart, the name of the cosmetic is put into the buyer with a string
still im not sure whats stopping you from doing this. the steerAngle seems to just be a float, so cant you just assign 15 to it then if thats what you want?
Unfortunately no, I'm using MoreMountains Feel to control the rotation of the wheelSteering controller, so need to grab the y rotation of the controller and feed it to the steerAngle (it's just an experiment at the minute cause I was curious). and yes, the steerAngle is just a float.
then you might be fine to just read the euler angles. there might be issues since rotations are stored as quaternions, it will have to convert to euler. it may not convert to the values that you're expecting since multiple euler angles can be the same rotation
Yeah, I've been looking around, but can't seem to find a way to convert from Quaternion to Euler (I only need the Y component). Couple of things I've tried just spit out the quaternion value. 😕
How'd i go about accessing the owner of a script component?
for some reason adding .gameObject at the end doesn't work.
Blind as a bloody bat. lol.
Thank you.
At the end of what?
Every Component class does have a gameObject property
Alternatively:
https://docs.unity3d.com/ScriptReference/Quaternion.ToAngleAxis.html
Since you only care about one axis
Ah nevermind that doesnt work like I remembered lol
I thought there was a method to extract one axis
lol. Sokay, and tbh the first one you posted I don't think works for my use case, because the code examples show that you need to know the Euler angles beforehand 😕 I'll keep searching. lol.
I'm using meta's all in one XR SDK, in a script there's a var called _grabbable, when i tried to debug print that variable, it gave me a grab component within an object, which is expected
It was bawsi but uhh it should work
I mean, it does work. What did you try?
however, when i try to drbug print _grabbable.gameObject, it returns an error
as if _grabbable (being reffered to as IGrabbable) doesn't have a .gameObject
Are you sure that grabbable is a component though?
Ah IGrabbable, looks like an interface
not exactly sure, that's why i tried to debug it, which gave me a component inside a gameobject
(real quick how do i do small code blocks here?)
If you definitely need its gameobject and it is a component, you can cast it to Component first
!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.
@nocturne kayak So something like (Component)_grabbable.gameObject
public void EndTransform() {
Debug.Log("Owner of this shit is " + _grabbable);
_grabbable.Transform.position = new Vector3 (0, 1.431f, 0);
}
Might need to wrap grabbable in paranthesis too, not sure
gives this
public void EndTransform() {
Debug.Log("Owner of this shit is " + _grabbable.gameObject);
_grabbable.Transform.position = new Vector3 (0, 1.431f, 0);
}
Oops, my bad. Sorry.
gives this
Oh if the IGrabbable interface has a Transform property then use that to access gameObject
Trying this out gives the same error as second option
Interesting
How do i do that?
Just try this but replace .gameObject with .Transform
Or .Transform.gameObject, not sure if it prints the same info
Alright, that compiled
let me try it out
Shit
that works
now my question is
why does that work
Well every Transform is attached to a gameObject
oh
ok
i think i got it
i'm still not used to thinking of the Transform as a component itself
And so is every component, but you are dealing with an interface, not a component type directly
this problem.
I was trying to figure out the owner of the component in the first place to try and force it's transform into a specific position to see if that would mitigate this problem
I managed to do that, it doesn't solve anything.
public void EndTransform() {
Debug.Log("Owner of this shit is " + _grabbable.Transform.gameObject);
_grabbable.Transform.gameObject.transform.position = new Vector3 (0, 1.431f, 0);
}
this causes the same problem
kinda nearing my (limited) wit's end here
I'm becoming very frustrated. lol. Surely there's a way to convert a quaternion to euler, without you needing to know what the euler is in the first place? lol.
To convert from Euler angles to quaternions, you can use the Quaternion.Euler function.
To convert a quaternion to Euler angles, you can use the Quaternion.eulerAngles function.
hi does anyone know how to see custom event parameter statistics within dashboard!? i see how many tiems event got called but i dont see a parameterthat i pass in !?
example i have a buy event .. that records how many times people bought items right.. i also pass in how many coins got spent but these coins are not showed anyware within dashboard!?
i see it as a parameter uder event explorer but they aint sohwing up in dashboard when i create a report
Honestly I could be using it wrong, but the eulerAngles thing just doesn't seem to work at all.
Vector3 wheelControllerNewRotation = wheelSteeringControllers[0].eulerAngles;
Supposed to return 15. lol.
What are you talking about? It is just myQuaternion.eulerAngles
The code is correct. Something else is wrong
Maybe show more of your code
I have no clue what it could be tbh. The object in the scene is rotating properly and the inspector shows that it rotates to 15 degrees. Seriously confusing the poop out of me. lol.
😂😂 if we DM I can help you out more
if (Input.GetKeyDown(leftKey))
{
wheelFLturnController.PlayFeedbacks();
Vector3 wheelControllerNewRotation = wheelSteeringControllers[0].rotation.eulerAngles;
Debug.Log("Wheel Collider Rotation = " + wheelSteeringControllers[0].rotation.y);
wheelColliders[0].steerAngle = wheelControllerNewRotation.y;
}
That's the entirity of the code that's delaing with this. The feel controller is what is rotating the option on the keypress, and that works fine, reports the correct rotation in the inspector etc.
It's just getting that value and feeding it into the WheelCollider.steerAngle. 😕
You are logging the y of the quaternion, not the y of euler angles
Not the same thing at all
Sorry, I changed the debug to check something and forgot, but using this...........
if (Input.GetKeyDown(leftKey))
{
wheelFLturnController.PlayFeedbacks();
Vector3 wheelControllerNewRotation = wheelSteeringControllers[0].rotation.eulerAngles;
Debug.Log("Wheel Collider Rotation = " + wheelControllerNewRotation.y);
wheelColliders[0].steerAngle = wheelControllerNewRotation.y;
}
Does the same thing.
🤷♂️idk what are wheelsteeringcontrollers. I assume they are transforms? Are you 100% sure you are looking at the correct object?
Also what you see in the inspector is local rotation. Here you are using world space rotation
I get the same thing using local 😕
You are likely using the wrong object then
Or something else is resetting its rotation between frames
Definitely not the wrong object 😕
Thanks for trying to help though, I do appreciate it. I've asked the question in the Feel Discord too, in case it's something to do with the way Feel works.
Didnt know you are using an asset.
It might be an execution order issue. If you are currently using Update, I would try LateUpdate @ruby python
Aaah, that's a fair point, that didn't occur to me.
Dear god, now I feel like a complete idiot. lol. LateUpdate fixed it. Thank you.
Nice
Hate it when it's something really stupid like that. lol.
There is no way to have these type of statistics in Unity AFAIK
Make them yourself
If you simply want to debug how the event is called, you can also just create a general method to call the event, and then log the parameters being send before invoking the event
But with how many events an application might have it makes no sense to add statistics to all of them
i know how teh event is called .. i want to trakc how many coins users spend buying items , and how many they gain selling them simple as that
but anyways thanks i guess unity is not that advanced to trakc such simple things
It's not about "being advanced". Your question revolves about your game requiring this type of information to function and Unity doesn't hold your hand with that.
It's a game engine, it doesn't support these niche features. It's not hard to add these yourself anyway
lol they track ur current user acqusitions but cant track a simple float form a event ..
yeah point on bud
it takes literally 10 seconds for you to write the code to track this yourself. its not about them being able to. if unity even tried to keep track of these things, itd most likely be using reflection and would be just worse in every way.
unity doesnt care about such a niche use case
Yeah because these two things totally relate with eachother
I think I was clear, what you ask for is something you have to do yourself
If that's something you don't understand then I'm afraid your expectations of a game engine is too high
oh does it !? can you do it ?
no i dont do your work for you
here we go
If you don't know how to do this yourself then I suggest you !learn Unity. Maybe you could even begin with learning c# first before taking on Unity depending on your experience.
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
did i say that i dont know how to do it !? im allreayd trakcing that within firebase .. and there it works simle as that .. in unity analitycs it dos not thats why im here asking for info ..
and you guys are werry helpfull thanks a lot 😉
Great, then I'd suggest you figure out how to send analytics data to Firebase and send this data each time your event is called
Again, niche use cases are rarely supported. Look more broadly on the matter and you'll see it's often quite simple to implement
Perhaps this is what you need? https://firebase.google.com/docs/database/unity/save-data
as i said this part is allready done. question was simple if you could track a float/int from custom event within unity analytics ..
The answer was ** probably not**, but somehow this was too difficult to accept for you judging by the conversation that proceeded
Also, if you are aware this exists, then what is the problem? Call these methods when your event is invoked.
for get it
there is also the #archived-unity-gaming-services which would be more relevant for this kind of stuff
I never worked with analytics, but this page seems to answer, that it should be possible: https://docs.unity3d.com/ScriptReference/Analytics.Analytics.CustomEvent.html
im allready talking about this
he pases in these values right
int totalCoins = 100;```
i just need to know if you could trakc these within dashboard .. as a metrics that accumulates etc.
cause this value is alrleayd there within event right
I don't think Unity Analytics would work with Firebase but that is not something I have experience with
So do you want to see it in unity analytics dashboard or within firebase?
i dont need it to work with firebase
ah okay
no
my firebase allreayd reflects this.. lets say 2 identical events..
in firebase i call sellItem(itemPrice) in firebase it sohws me how many sell items evnets ogt called and whats the total value of itemPrice accumulated
within unity dashboard i do the same tihng but i see only event count
Ah, got it. Well, then I geuss what the others said states. Analytics is just lower level in providing pre filtered or processed information. You might need to do it yourself with sql explorer or similar. Information coming from: https://support.unity.com/hc/en-us/articles/30417903024020-How-to-view-a-glossary-of-Unity-Analytics-event-parameters
even thoes itemprice is part of the event
got it thanks
basicaly a lot more hustle
I guess its in the matter of time firebase has been around and being used vs analytics being younger. But yeh, if it does not fit your needs, just stick to firebase or try to combine them or do the little extra work if you want to analytics. guess thats all there is to conclude
I see, this was not clear from what was said
Then perhaps this could work for you
Like I said the analytics part are not something I'm too familiar with, but it seems unlikely that these are just baked into random parts of the code. It really depends on your needs.
Hey Hey!
Is there a Rule of Thumb what I want in the ECS Subscenes and what not ?
ECS is too advanced for in here and has its own section #1062393052863414313
. here @tulip crystal
check the 2 pin messeges
Bruh which course
click into to c#
im currently working on cooking/crafting part, certain ingredient cannot be processed certain way aka you cant cut water, cant tenderize egg, etc.
currently i have the information required for crafting kind of detached. i leave the value 0 if something isn't meant to be processed a certain way.
so how do i approach this, i want to have somekind of bool in editor that expands when its true, so i can input the required data for crafting
instead of leaving many empty
i could separate them into multiple classes but it feels like that will make it unnecessarily complicated
what should i look into ? interfaces ?
Alright gents, I have made progress
now I need to figure out how to have a Slider Component in the UI [MotorSpeed] change the value of a variable [speed].
Check the available callbacks in the slider class.
Im somewhat confused what you're trying to solve here. Is it just that you want it easier to setup crafting recipes so that you dont have a ton of options visible at once?
You could look into editor scripting to show options based on a condition. I think there are some premade assets which have attributes for this as well.
You could try to attach functionality with interfaces and classes, but this really depends what you're doing. I'm assuming you'd do an action to an object and itd just turn into another object. The code for this would likely be the same across most actions
yes the code is similar, but the required value will be different across different process. for meat i would make 4 cuts at 60 work per segment = x milisec per segment times 4. tenderizing would be 10 smacks 20 work per smack etc
I have this code on all my slime. what it does: looks for slimes that bump into each other does X. this one in particular is spawning a new slime. Since it's on every slime, of course this ends up spawning two. Any ideas how to make it spawn one, while leaving the script on every slime still?
Honestly good question
I can't think of a simple way
handle the spawning on different script
If you want a not-so-simple way, create a lock
For example, SemaphoreSlim
If it's locked, don't spawn
If not, you're the first slime to enter
Though this solution sucks
How is this supposed to help?
I dont believe I used a lock before so I would have to look into that
You can also use the lock keyword
send the location to the spawnmanager, instantiate there
But idk how you can tell the other slime to just not spawn anymore then
They still both call this method and two slimes spawn so this still doesn't work
honestly the suggestion of handling it on a different script would probably be easier. just have each pair of colliding slimes contact that other component and provide the pair that are colliding, then like pairs are filtered down to just one by that script, then toward the end of the frame it spawns one slime for each of the remaining contact pairs
You could maintain a counter which the slimes make go up on collission
Then, at the end of a frame, divide it by two and spawn the number of slimes. It's just having to maintain a reference to the slime so you know where to spawn it
Basically what Boxfriend said in that case
OK thanks will give another script a try !
i have a question. i have this bullet that is instantiated by a turret and I was thinking of making a function that once the target is dead the bullet is destroyed. so no random bullets flying out the map. I came to the knowledge that what i did was deleting the prefab instead of the copy. so my question is where do i put the function of destroying the object. the script of the bullet or on the script of the tower?
self destruct the bullets after x time?
either one works if you want to do it after a certain amount of time, you can pass a delay to Destroy so you could instantiate it then immediately call Destroy with that delay, then if it hits the enemy or whatever it will destroy it like it already does (i assume), but if it misses it will then still be destroyed after that delay time
i'm thinking of destroying it once the enemy is dead. since there are still bullets at times that is still going for the enemy right after its death
i think it would look weirder having all travelling bullets delete when they die?
typically when a bullet collides with something, it destroys, else destroy it after X time to stop stray bullets in the sky etc
hard to say without knowing ur game though 🙂
i see. thank you
you mentioned tower though, is it a tower defense?
you might want to pre-calculate whether the bullet will kill that target or not, so you can change target for new bullets while the old bullets are still travelling.
that would make your turrets seem smart and not waste shots on things that are going to die
so I will make a code that changes the target of the bullet every time their enemies are deleted?
their targets rather
Nah. I would have a 2nd hidden health value on each enemy, and whenever you shoot a bullet at that enemy, instantly deal damage to that hidden health.
You can have multiple turrets shooting at that enemy, but as soon as a turret makes it reach 0 / go negative, it changes target.
so before shooting, check their hidden HP and change target if its already gonna die to bullets u already fired
Theres a trick, you can compare their GetInstanceID() values. For example, only run the code on the instance that has the greater ID
Since instance ID's are never equal it will always filter out one of the objects
oh sweet that's a great idea, hang on lemme try it
it's spawning two
@verbal dome any idea what I did wrong?
I just had to make sure they were gameobjects haha, it works now, thank you!!
does someone know if there is a way of doing the following
if(_interactionState == (InteractionType.Building | InteractionType.Buying | InteractionType.Expending))
_currentState = CharacterState.Normal;
instead of the following
if(_interactionState == InteractionType.Building | _interactionState == InteractionType.Buying | _interactionState == InteractionType.Buying)
_currentState = CharacterState.Normal;
How to post !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.
come on*, its understandable the way I put it without me needing to post on this site
Small bits of code with the inline guide else use a free code sharing service (links provided above)
okay
does someone know if there is a way of doing the following
if(_interactionState == (InteractionType.Building || InteractionType.Buying || InteractionType.Expending))
_currentState = CharacterState.Normal;
instead of the following
if(_interactionState == InteractionType.Building || _interactionState == InteractionType.Buying || _interactionState == InteractionType.Buying)
_currentState = CharacterState.Normal;
now I'm happy
I didn't realise that you can do that
switch (_interactionState) {
case InteractionType.Building:
case InteractionType.Buying:
case InteractionType.Expending:
_currentState = CharacterState.Normal;
break;
}
not any way of making it shorter?
Switch also prevents you from making duplicates like you have in your second example
switch is much more readable and maintainable
yeah, I realised that... okay, gonna use switch
if(_interactionState is InteractionType.Building or InteractionType.Buying or InteractionType.Expending)
That's weird. Any chance you can log both ids before the comparison? Maybe we can check how often it's logged and also see what it compares
they already solved it
Oops, missed the picture below it
You could do this:
InteractionType[] interactionTypes ={};
if (interactionTypes.contains(_interactionStates))
_currentstate = CharacterState.Normal;
that's what I was looking for, thanks
this can hipercomplicate thigs I think
Pattern matching exists for this like Nitku showed
Doesn’t that only work for types and enums though?
what does your enum declaration look like? show the code
When the object is added to your cart, the name of the cosmetic is put into the buyer with a string
later, Already got what I wanted, thanks for the help tho
I need to make a script for that
No, it works fine for values and such too
Ah. My bad then.
Anyone have any idea why this wont work?
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class SubtitleController : MonoBehaviour
{
[SerializeField]
public List<string> Subtitles;
public List<float> timeToWait;
public GameObject subtitleText;
public Wizardthings Wizardthings;
public void SubtitleStart()
{
if (Wizardthings.linePlaying)
{
StartCoroutine(TheSequence());
}
}
IEnumerator TheSequence()
{
if (Subtitles.Count != timeToWait.Count)
{
yield break;
}
while (true)
{
for (int i = 0; i < Subtitles.Count; i++)
{
subtitleText.GetComponent<TextMeshProUGUI>().text = Subtitles[i];
yield return new WaitForSeconds(timeToWait[i]);
}
subtitleText.GetComponent<TextMeshProUGUI>().text = "";
}
}
}
what doesnt work
The text won't change.
does the code even run?
yes, you really need to add some logging
I'll try to debug.log it. How did I even forget to do that in the first place😅
Oh no. It doesnt even run
you do realize you have an infinite loop in there as well?
I mean that was kind of the point to try and get it to run the subtitles as long as there was strings and floats in the lists
that will just loop over the same data ad infinitem
oh
you dont need the while loop at all, the for is enough
so find somewhere to call SubtitleStart();
Like where? It should run when my lineplaying is = true
Should I make an update void and add it there?
why would it do that if the method is not called?
Methods dont get automatically called unless its one of the Unity methods (Update, Start etc.)
technically you can but then you have to set Wizardthings.linePlaying to false when you start the coroutine, otherwise you're gonna call the coroutine every frame
That's not too hard
not how I would do it
public void Start()
{
StartCoroutine(TheSequence())
}
IEnumerator TheSequence()
{
yield return new WaitUntil(() => Wizardthings.linePlaying);
question. how can i use a timer script i made, to use that as a win condition? i want to disable the movement script i have when the timer runs out
I just put it like this
IEnumerator TheSequence()
{
if (Subtitles.Count != timeToWait.Count)
{
yield break;
}
for (int i = 0; i < Subtitles.Count; i++)
{
subtitleText.GetComponent<TextMeshProUGUI>().text = Subtitles[i];
yield return new WaitForSeconds(timeToWait[i]);
}
subtitleText.GetComponent<TextMeshProUGUI>().text = "";
yield return new WaitForEndOfFrame();
Wizardthings.linePlaying = false;
}```
just run a method when the timer reaches 0, and do the stuff you need to do?
now why would you do that?
im saying idk how to access the movement script through the timer script
make a variable and drag it in the inspector
i was trying to do that, but it wasnt letting me
can i post pictures in here or will i get in trouble?
So it waits for the end of the frame to disable the lineplaying bool so it doesnt start the sequence each frame?
were you dragging a scene object into a prefab?
Are you trying to drag a scene object into a prefab?
lol
so when do you think this executes?
Wizardthings.linePlaying = false;
On the start of the frame I guess...
no at the end of the coroutine, and how many frames will have passed before that happens?
Oooh. So how should I do it then?
if you must use Update you want to do that immediately the coroutine starts
i was trying to drag the script into the field thing (idk the word) i have the timer setup as a TMP and im running a basic countdown script
So just like this
IEnumerator TheSequence()
{
yield return new WaitForEndOfFrame();
Wizardthings.linePlaying = false;
if (Subtitles.Count != timeToWait.Count)
{
yield break;
}
for (int i = 0; i < Subtitles.Count; i++)
{
subtitleText.GetComponent<TextMeshProUGUI>().text = Subtitles[i];
yield return new WaitForSeconds(timeToWait[i]);
}
subtitleText.GetComponent<TextMeshProUGUI>().text = "";
}```
dont need the first wait, it's pointless
oh yeah true
i was trying to make a singleton but idk if i was doing it correct. i made a the script a local singleton, and was able to access the components, but i wasnt able to put them into the field @deft grail
Works like a charm, thank you!
actually, looking at what I think is the logic you are trying to implement you probably want to move this
Wizardthings.linePlaying = false;
to after the first if statement
Why?
because you want to wait until the Subtitles List is full
but still try to run the coroutine until it is
Are both objects in the scene
i have the timer in the scene
would i be able to access the timer value through the TMP? is TMP stored as Text where i can just go if timer == value do X ?
And the object you're trying to drag it onto as well?
no, i can't put the script into the scene
to rephrase, im trying to make it so that when the timer reaches 0, the player movement is halted, and the game is finished, so then i can change the scene
why not
idk?? is that a thing im supposed to be able to do? (im new to unity)
What thing are you trying to drag onto what other thing
i wanted to use my timer script as a reference:
{
[SerializeField] TextMeshProUGUI timerText;
[SerializeField] float remainingTime;
// Update is called once per frame
void Update()
{
remainingTime -= Time.deltaTime;
int minutes = Mathf.FloorToInt(remainingTime / 60);
int seconds = Mathf.FloorToInt(remainingTime % 60);
timerText.text = string.Format("{0:00}:{1:00}", minutes, seconds);
}
}
so i can then make a win condition within my player script
im unsure how to set this up tho
i want to be able to access the remainingTime specifically
rn im trying to access it through the inspector, but either way will work for me. again, im unsure how to do either though
So you want your player script to reference a timer, or the timer to reference the player script?
player script to reference a timer, so that when the timer runs out i can halt the player script
if you are trying to access that variable from another script you must make that variable public and remove the serializedfield and go into the script you want this variable on and use Getcomponent function to get the script
and then use the variable
and for the inspector either make it public or private with [SerializedField] (this way is preferred if you do not need to access this variable)
Ran in to a new problem. I want to have another reason to have other subtitles, but this didn't work. How can I do it properly?
public void SubtitleStart()
{
if (Wizardthings.linePlaying)
{
StartCoroutine(TheSequence());
}
else if (Wizardthings == null)
{
if (WizardHitLine.linePlaying2)
{
StartCoroutine(TheSequence());
}
}
}```
the Getcomponent will go in the timer script?
Okay show the inspector of your player object
no in your player script
I thought you had moved that to Update?
I did. There is a c# public void Update() { SubtitleStart(); }
also it makes absolutely no sense to check something for null after you have already used it
Yeah I thought that too, but I don't know how to check it the right way
switch the if statement the other way round
ok
If that's happening then either something is changing it after the check, or the thing you're checking and the thing that's null are two different things
if you cannot understand basic logic, programming is not the job for you
Ah wait, just got into this, I thought the issue was a null check was failing to detect a problem, seems like it's just a pointless null check and the error would have already occurred
still scrolling back up
Oh come on. I do understand why it didn't work now, either way it still doesnt work
NullReferenceException: Object reference not set to an instance of an object
SubtitleController+<TheSequence>d__7.MoveNext () (at Assets/Scripts/SubtitleController.cs:38)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <54724222b7684530a2810ae1eac94ec7>:0)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
SubtitleController:SubtitleStart() (at Assets/Scripts/SubtitleController.cs:22)
SubtitleController:Update() (at Assets/Scripts/SubtitleController.cs:33)
So, what's line 38 of SubtitleController?