#💻┃code-beginner
1 messages · Page 36 of 1
yes
damn
public fields are poor practice. Public functions and properties are ok
glad I use [SerializeField] mostly
if float1 was a property though, the first example is ok
ok thank you so much
yea i could try that, though idk how to control direction, but pretty sure i can search it up. thanks
How would one save text from an Input Field and load it on launch
cheap way : PlayerPrefs
good way: save into a file
alright, how would i save it into a file?
JSON usually
using System.IO class to create a new file
ok thanks, i'll look into it
its not text from a field but the same concept applies..I typically do explenation, this one just runs thru it without explaining but most of it is self explanitory i thnk
https://youtu.be/Q0_xreJMldM
pro tip: there are methods to read/write all text from/into a file
you don't have to open a stream and then do a 20 line song and dance, as I originally did
🫠
var text = JsonConvert.SerializeObject(data);
System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(Path));
System.IO.File.WriteAllText(Path, text);
e.g.
Is that the TextAsset class?
you can skip line 2 if you're just writing into Application.persistentDataPath
no, that would be for a text asset you build into the game
How do i get the data from the input field?
OnValueChanged or OnEndEdit
or .text
ok thanks
how are the outline effects/shaders achieved
One way is to push the mesh outwards a little and render its backfaces
Another is to do the outline as a post-processing effect
https://bgolus.medium.com/the-quest-for-very-wide-outlines-ba82ed442cd9 has a nice discussion of that
bless bgolus
ty, I searched "unity outline shader" and didn't amount to anything other than errors ill check that out
https://github.com/alelievr/HDRP-Custom-Passes includes an outline effect as an HDRP custom pass
which render pipeline are you using?
Why am i getting a error at the foreach statement: https://i.imgur.com/jT5iPpv.png
Yes
You're iterating over Transform but trying to store the result in GameObject
Can't cast Transform to GameObject. I was honestly expecting that one to be a compile error, not a runtime
oh ok
Hey I have a question, why Vector3.zero.normalized is not normalized?
When I try to print that out it returns vector 0,0,0
what would you expect it to return?
it's actually something that doens't make any sense at all
No idea, but normalized is supposed to be always of length 1, right?
a normalized vector is one in the same direction but with length 1
what direction is Vector3.zero pointing in?
The fact that it returns 0,0,0 instead of throwing an error and crashing is a concession
Mathematically, it should cause your program to explode
Yeah I thought it will throw an exception 
It's basically like dividing by zero
Indeed
if this is something that comes up in your game, simply check that the vector isn't 0 before doing it
Since normalization is mostly used to get the direction of a vector, rather than for pure math, they figure "no movement = no direction"
Well, I need to put Vector3.Dot() and 2nd argument is the Vector3.zero point, and as you know for dot product both vectors needs to be normalized
that doesn't make sense
I need to find out if player is looking at the center of universe
I mean at point 0,0,0
the dot product takes two direction vectors
Vector3.zero is not a direction
The dot product of a 0 vector also doesn't make sense
If you think your player's look direction vector is Vector3.zero there's something wrong in your program before this point
looking at zero is not the same as having zero as the look vector
if I'm standing at 1, 0, 0 and looking at 0, 0, 0, my look direction is -1, 0, 0
If i'm standing at 0,0,0 and looking at 0,0,0, then I've just ripped a hole in the spacetime continuum
that's kinda like looking at your own head
Right, I just realized I guess 'm doing something wrong
Yep, exactly, my bad. Thank you both!
I've just found this ||@wintry quarry@polar acorn||
could someone help explain how i could have my players full sprite with all child gameobject sprites together as another image inside of the inventory?
i heard i should use Render Texture, with a Raw Image
but im confused how to do this
i have made a 2nd camera with a raw image and idk what to do yet
did you throw the render texture into the Raw Image component?
Basically i’m here to learn unity i’m not even beginner i’m too bad at programming.
Help me out
!learn
:teacher: Unity Learn
Over 750 hours of free live and on-demand learning content for all levels of experience!
:teacher: Unity Learn
Over 750 hours of free live and on-demand learning content for all levels of experience!
Yes that is the command I sent you why did you type it again
anyone knows what this refers to ?
as in where to find it
realised this is the place:
But it still dont work any ideas what I need to adjust config wise? I am using unity Localization package
I'm getting this error for this script. Could someone explain what the error message means to me? I already added a Circle Collider 2D to the game object.
The parameter type of your function is incorrect
OnTriggerEnter2D does not take a Collider as a parameter
Oh, I see. Should I change it to Collision?
You should look up what type it takes
Idk
Oh, it takes Collider2D. My mistake, thank you for your help!!!
anybody know a fix for this?
Pretty sure += and -= increment after use, so it's clamping, then adding. Put the += and -= on separate lines, then run the clamp afterwards
Is Vector3Int serializable or am I crazy
Im making a game about you being in the woods camping and you see a big nest and you have a gun. And you have to kill all the spiders that come out and you have to survive waves. And at the 10th wave you see a HUGE spider and you kill it. And if you beat it a cutsene will play where you take hair spray and a lighter and light it on fire and it blows up. Then it says to be continued and i need mods any body wanna help?
strange, will try that
Do you have an actual question
yes i need help with invers kenimatics here in a bit
Okay, so ask the question
can you help
You haven't asked a question yet
I asked if you can help me with it i've never done it before.
Do you have an actual question or are you just trying to get someone to commit to solving your problem before you've even said what it is
The server rules are that you should just state the specific issue you have and someone might help. No need to ask if someone can help
I'm making a mod for Gorilla Tag, a VR game, and I have no idea what I'm doing. I have the mod template but I cant figure out how to code this. All the mod does is puts an object in a certain place.
Bub, I am asking if you want to become a dev for my game. That is the question. If you don't want to say it, don't waste my time.
but ill go to the thing
!collab
We do not accept job or collab posts on discord.
Please use the forums:
• Commercial Job Seeking
• Commercial Job Offering
• Non Commercial Collaboration
"bub" bro thinks hes wolverine
Bruh, best come back of the year.
It's against the rules to ask that here
oooohhhhhh
thx for telling me
not twice once
ooooohhhhh srry bout dat ill use the thing you sent me
must be something weird with changing the source time in general when it comes to the ends bc that doesnt work either, the debug logs are there to confirm it is clamping properly
it works completely fine when seeking left and right in the middle of the audioclip tho
jsut has trouble with the ends
float newTime = src.time + 5;
src.time = Mathf.Clamp(newTime, 0f, clip.Length);
Add first. Then clamp
yeah i tried that before and it diddnt work so that code screenshot is my newst attempt at a solution
seeking left out of bounds does actually reset it to 0 but still produces that wonderful red error saying its out of bounds, seeking right out of bounds just produces the red error, but twice
Try this, with new log:
float newTime = src.time + 5;
newTime = Mathf.Clamp(newTime, 0f, clip.Length);
Debug.Log($"Setting time for clip to {newtime} / {clip.Length}");
src.time = newTime;
And show the log right before the error comes up
ok so looks like it works now ( istg i wrote the code exactly like that ) but only for going below the bounds, going beyond the bounds still produces an error ( only 1 this time! )
Looks like it doesn't like time being exactly the length of the clip
You probably want to subtract a small amount from it
inside the clamp, try clip.Length - 0.001f or something similar
also hey i diddnt know you could do $"blah blah blah hey check out this variable its {varName} isnt that cool" instead of "blah blah blah hey check out this variable its " + varName + " isnt that cool"
Yep, it's called String Interpolation and it's great
holy hell
what the hell
why is 27.2185 - 5 = 0
i love math, especially when it makes sense
so yeah no big scary red errors but now this is happening
What's the code look like currently
should I post all of it too?
At least the two Seek functions
for context of what im doing, its basically a mini audioplayer
can I use CharacterController in some objjects, and rigid body in other objects if its convenient for the gameobject in the same game?
hitting the end of the clip seems to freeze up the playback entirely, no seeking back or forward, just doesnt do anything, but the values being recorded are max value of clip - 5 = 0 and max value of clip + 5 = 5
Strange. Try changing the log to include src.time as well:
Debug.Log($"Setting time for clip from {src.time} to {newtime} / {clip.Length}");
Yes as long as you don't have both on the same object
nicee
and also if you don't expect any of the rigidbodies to move around the character controller
it's just gonna shrug off any forces that hit it
first image is seek left from max, second is seek right from max
seems to reset to 0???
which i kinda get but ???
wait i got the worlds worst idea
oh ok i think i found the issue
unity's handling of looping audio clips is just weird
i had to toggle on looping for the audiosource and it works but yeah it loops now, easy fix tho.
thank you unity very cool
thank u btw i was completely bewildered and there wasn too much info online i could find lol
Hi im relatively new to unity and i was just curious on i could replace my transform movement with physics movement? Can anyone help me?
Put a rigidbody on your player, reference it in code and then use the MovePosition or AddForce methods, depending on what you want to base your movement on
can the PropertyDrawer of list be manipulated? I dont wanna see the Element x thingie in here
public class MyList<Type> : List<Type>
{
}
Then edit the propertydrawer of "MyList"
what a hack, nice !
I dont know what the hell this is but it looks cool...trying to make circular shaped pattern for enemy attacks
is applying gradient noise to shader expensive??
I'm getting a CS8803 Error with this area
I would like help finding out what to do with this and for clarification it for terrain generation
Are you using notepad for coding..?
Also, why a photo?
People don't usually have error codes memorized, and the same code can have different messages. What does the TEXT of the error say?
But I can't tell from your screenshot, do you have an opening curly brace for the class?
public class TerrainGenerator : MonoBehaviour
{ <- this
}
It looks like it is missing
Seems like it. 
@broken hazel Oh dang. Just realized you can see the super pixellated and blury error message at the bottom! Nice.
I'm gonna say it's the missing curly brace, since it is complaining about top-level statements
Also next time. Windows + Shift + S.
My laptop slow
I don't see how that correlates with taking photos...
Or even just sharing the code 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.
I also don't have discord on my computer
It's available in the browser, or you can download it.
Just... don't take photos of the screen please. It is awful haha
Or hell, copy the code, email it to yourself, send it via your phone
Millions of ways to do it lol
Lol and your thing worked
Ty
Get yourself an ide. If your computer can handle unity, surely it can handle VS or VS code too.
if i make a variable can it be called in any script or just the script its made in
A variable declared in a class -- a field -- can always be accessed inside the class that declares it
If the field is public, then any class can see it
If it's protected, any child classes can see it
If a field is not static, you must have a specific instance of the object to access it
If the field is called foo, then, within the same class, you can write this.foo (or just foo) to access the field
that will give you your own instance's copy of foo
If you have an instance of the class stored in a variable named bar, you can access the field with bar.foo
(assuming that the field's visibility lets you see it)
Hey, how often is OnGUI() method called? If I google it's allegedly called a few times more than Update() but no info how many times exactly
I know that it gets at least two calls.
- There is no exact number
- Why are you using OnGUI
i use OnGUI pretty frequenetly to make debug interfaces
hey how do i make a simple system to check when an object is touching the ground?
you should not do anything in OnGUI that changes state if it doesn't involve calling a GUI method. So Time.timeScale = GUILayout.HorizontalSlider(Time.timeScale, 0.25f, 2f); is fine, but player.health += 1; would be a bad idea
you'll want to look up "unity ground check" for some examples
but two good options are:
- shoot a raycast from the player's center towards the ground and see if it hits anything
- use
Physics.CheckSphereto test if any ground colliders are near the bottom of the player
(or, in 2D, use Physics2D.OverlapCircle / Physics2D.OverlapBox)
okay ill look into that thanks
To use GUI.Label() method. No exact number? Weird 
it should not matter to you
Aight
you should not be doing anything in OnGUI that depends on the exact number of times it's called
Yes, but why are you using GUI.Label? Are you making a debug GUI or are you making a full UI for a game? Because it's only use these days should be the former
I only discovered that it gets called multiple times while doing some logging. I never noticed for quite a while
even modders should be using UI Toolkit 😛
Got it, thanks!
i should figure that out, eventually
hmm, the second method seems convenient, but is there any way to make it not check in a square or a circle? a long rectangle would work better
CheckBox checks a rectangle
oh it takes a vector2
whether using 2D or 3D
for some reason i read that as a float
it can be any combination of side lengths
yea got it
Well, doing some playground to experiment with calculations and to easily print it to the screen I use GUI.Label()
Sure 👍 that's a fine usecase
hi im back
so in row 54 there is something wrong and in the one that is similar. Can you help me? i can give the error code if that helps
You are required to use an !ide to get help here
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
We can't even see line numbers like that? Do you expect us to count lines? 🥴
you put an = instead of a +
float xCoord = (float)x / width * scale = offsetX;
float yCoord = (float)y / height * scale + offsetY;
float xCoord = (float)x / width * scale = <-- here offsetX;
float yCoord = (float)y / height * scale + offsetY;```
@cerulean stirrup #854851968446365696 also says not to give answers to people without configured IDEs
im using vscode and its not autofilling. i have the unity extension, and it was working a bit ago-- idk what changed
Did you follow every single step?
i fixeded it
Top to bottom. No creative interpretation, no skipping steps, no substitutions, no "it's probably good already".
ty again lovely people
well not from the beginning, since i already configured it a while ago, do i need to uninstall stuff?
From the beginning. You do not need to uninstall anything, but you do need to ensure that every single step has been accounted for.
Seriously get an ide. You have NO IDEA what a gamechanger it is. I would stop all work until doing it
After doing this, you should also restart the code editor and, if it's still misbehaving, look in the Output logs for the extensions
row 54 shows pic of notepad 
alr ill force my store to work
just use VSCode. it'll work fine
ah, got it. thanks a ton, i had to read closely
was it the Visual Studio Editor package?
obnoxiously, that thing is locked by the "Engineering" feature by default
it was, when i set it up i used the visual studio code editor package which is apparently deprecated now, and my visual studio editor package hadnt been updated
indeed. this changed a few months ago
the Visual Studio Code Editor package has been deprecated for a long time, but now it's completely obsolete
any idea why this isnt triggering? i gave the floor the "floor" tag, and boxcollider2d
Might help if you drew a debug gizmo for it
whats that
and also use CompareTag instead of comparing tags using equality.
hmm, the physics debugger doesnt seem to detect the invisible box
What do you mean? Did you draw the box and it's not showing up?
oh do i have to manually draw the box in the code?
Either the code isn't running or the box is nowhere near where you expect
yes. physics debugger does not support 2d
so do i use the "gizmos.matrix" method from this forum?
does anyone know how to fix this error “Setting the parent of a transform which resides in a Prefab instance is not possible {GameObject: ‘PhotonVRVoice’).”
yes, don't call SetParent on a prefab
How do i do that😭

well look at where you are setting an object's parent and make sure that you aren't doing that to a prefab
Mk
Usually it's because you're instancing something and not then modifying the instance
Im so confused😭
If your code is throwing that error, send the code
Wdym
What are you having trouble understanding? Don't cross-post as well.
No body answered in gen chat srry
You need to wait at least a few minutes to get an answer.
Following the "asking questions" guidelines in #854851968446365696 can help get help faster too.(or at all)
Im abt to just quit on this game😭 ive had to restart over and over for almost a year now bc it breaks every time
do i need to be worried about the layermask?
How is it that you can't fix(or at least understand) that error after working on it for an year..?
i cant find any way to fix this issue (not even sure how to draw a box)
Idfk💀
Im stupid in the head
More likely that you didn't learn the basics properly or trying to work on something you're not ready for yet.
Start from breaking down your code. See if that overlap detect anything at all.
Its a gtag fan game that ive seen 8 year olds do better than me at😭
That shrug was uncalled for
The fact that it involves photon and vr, makes me really doubt that an 8 years old could implement it. Unless they are a genius and was studying unity and programming for a few years.
You probably SHOULD use a layermask to avoid that
Nah its smth with the photon voice
alright thanks
My error is smth with the photon voice
Your error was explained to you several times by now.
that's unlikely. it's most likely something with your code when you instantiate the photon voice gameobject
Im too dumb to understand
there are beginner courses pinned in this channel and on the unity !learn site
start with those
:teacher: Unity Learn
Over 750 hours of free live and on-demand learning content for all levels of experience!
!learn site
:teacher: Unity Learn
Over 750 hours of free live and on-demand learning content for all levels of experience!
That's an excuse.
You just didn't do any learning required for that project.
First of all, stop that.
Second, they asked for the code so they could help 🤷♂️
But yeah, this may be too much to start with? Unity's learn page would help
I did i just dont understand certain things
Then you miss even more basic knowledge that is required to understand whatever you didn't understand.
if only there were learning resources you were directed to that would help you begin to understand
Proper learning involves learning everything from the bottom up.
If you encounter something difficult during your learning, it's ok to ask the community. We might be able to explain or direct you to proper learning materials.
this is definitely not the tone you should be taking with people trying to help you. if all you are interested in is throwing yourself a pity party because you don't understand and you refuse to go through the beginner courses so that you can understand, then why are you even here? go throw your pity party somewhere else where someone may actually care
Again i did learn and ALSO again it doesnt always fucking work out, you guys are just lucky it did for you
any decent way to prevent objects falling at high speeds from passing through the floor?
lol it's nothing to do with luck. you have to put in the effort to learn
try turning on collision mode to continuous
where do you do that
anyways, unless you have actual specific questions, there's no point in continuing this conversation.
continuous collision detection on the rigidbody can help with that. but another way is to just not move things at super high speeds
It has nothing to do with luck. It has to do with perseverance. It also has to do with taking SMALL steps. Learning comes in many forms, and the form you took obviously didn't work for you. You can give up, or try another. But don't lie to yourself and say it has to do with you being "dumb" or others being "lucky". It's only been a year. That is nothing.
when i hit the bar it should show a game over sceren but that is not there, how do i fox this?
what is this?
the troubleshooting steps you need to take
what do i press?
Also, make sure to save.
life saver
please try and put at least some effort and thought into what you are doing
bro I dont get this
yes. so read it
then what did i do
well you're obviously working in 2d so clearly you need to click the "I am working in 2D" option
Are you working in 2d or 3d?
2d
Don't try to skip out on reading - fast reading isn't applicable.
also have you put a log or breakpoint inside of your OnCollisionEnter2D to check whether it is actually being called?
i was reading this "Comparing tags using equality; use CompareTag to get proper warnings.
Destroying components instead of their gameObject, leading to the appearance that nothing happens.
Ignoring errors that throw exceptions, these cause the code after to not run (fix the exceptions to resolve the issue)."
read the entire fucking page
So pick the appropriate one
WHAT THE FUCK IM I DOING
i did
You aren't receiving physics messages because likely your setup is incorrect. Follow the guide to ensure everything is correctly setup.
im on a tut
i did what he did but i might have to look more
im go i have to do sum rq
This is the solution.
ok thank you
Hey, how can I create multiple lines? I can't add multiple LineRenderer components to the same game object, is there a way to split that line into a few parallel lines?
make multiple gameobjects as siblings?
Most likely I'll have to
please ping me when replying to me
ping'd
better to keep multiple of the same components on multiple different GOs anyway
🪲 To make bug reporting as quickly as possible, we made a bug reporting application for you. When running Unity choose Help->Report a Bug in the menu, or you can access it directly through the executable in the directory where Unity is installed. It will also launch automatically if you experience a crash.
📝 If your bug report is to do with Documentation, either an error, typo, or omission, you can report it by scrolling to the bottom of the page where you found the issue and click ‘Report a problem on this page’!
💡If your report is to do with a new feature idea, you can check the Unity Product Roadmaps page to see if your idea has already been planned.
For more complete instructions on how to report bugs, access: https://unity3d.com/unity/qa/bug-reporting
has anyone an idea of why it is doing that ? Here is my little script to control my spider.
if you do not plan to rotate the object using physics then constrain the rotation on the rigidbody
ok yeah it works ty
also there are a few weird choices in that code. why are you rounding your input (which should just be -1,0,1 with digital input) then also clamping it to that range?
i guess bc with a controller its not always -1, 0, 1 ?
no ?
yeah the clamp should be useless tho
correct it is not, however if you want to support being able to move slower with a controller when not maxing out the joystick axes then you shouldn't be rounding it
yeah true, i'll remove it. I won't lie i took this piece of code online because i just needed a controller quickly, but now looking at it you're right
Now is still my biggest problem, i don't know how to change my transform.up with my cross vector of the legs without conflicting with the forward vector
We really need a counter of peeps who go profane against boxf 
i don't know what you mean by this so you'll probably need to provide more details if you want help
I am trying to set up a character which faces a particular forward direction and its up direction is direction is based on the normal of the mesh it’s standing on. So I do something like; transform.up = raycastHitInfo.WorldNormal; transform.forward = LookDirection; The problem is that I can’t seem to set both components simultaneously and ge...
this it not my post, but same problem
im looking at it right now
just add the vectors? nvm the problem was so deep to readback
i'm certainly not an expert when it comes to rotating objects like that in 3d since i mostly work in 2d, but from the looks of it the first two replies to that should cover it 🤷♂️
i need to get the LookDir from my input angle :')
i dont know how to do, maybe im missing something
funny it is that most ppl are good in 2D and doesnt work in 3D, this is my first project for uni and they throwing us in procedural animation in 3D with unity 👍
multiply the transform.forward by the result of Quaternion.AngleAxis(your angle to change, Vector3 representing the axis it should rotate around which is probably just transform.up)
okay i see what you doing here, seems cool
but i cant multiply and vector and a quaternion
yes you can, the quaternion just has to be on the left side of the multiplication operator
oh yeah
internet was telling me to do some intermediate calculus i was like "really ?"
thank you xD lemme try
ok its working for my controller, but when i put back the modifications of my transform.up it doesnt work and it doesnt move 
Here are my transformations of the transform up
how to select a random number from 0 to 3?
thanks
Can someone please help? For some reason my enemy only shoots to the right and does not shoot depending which side it is facing
it's most likely due to code on your actual bullet
btw that shootcooldown coroutine doesn't actually do anything
the actual bullet just has velocity
yes, and that velocity is sending it to the right
okay... I have a very specific question about execution order
line 33 in a script A instantiates a gameobject that has a script B on it
line 34 changes a value in script B
does this change execute before or after OnEnable in script B
after
Awake and OnEnable are called before Instantiate even returns
well, time for a workaround
what exactly are you trying to accomplish?
edit: does this change execute before Start in script B?
no, start is called later in the frame or even the next frame
so yes, the change of value from script A does execute before start in script B
wait, yeah i misread the question, but the info i provided is correct.
and the use - Im generating random environment blocks as the player is moving and starting it "low" and moving the enviro parts up as the player gets closer to emulate the feeling of looking into the distance
and the issue is, when I instantiate the "starting" blocks when you first load an app, they start low as well
using start instead of awake/on enable solves the issue
This is my Bullet Velocity. how can I have the bullet shoot to the left or right depending where the enemy is facing
either rotate the bullet so it faces the correct direction when you instantiate it, or you need to pass the desired direction to the instantiated bullet so you can apply that direction when you assign the velocity instead of just using transform.right
This code makes my bullet freeze for some reason
don't make it an int, just use a float. the cast is probably screwing it up somehow
it still freezes
print the values of your variables
It says "NullReferenceException: Object reference not set to an instance of an object BulletVelocity.Start () (at Assets/Scripts/Player Scripts/BulletVelocity.cs:18)" However I have Rigid Body Component for the Game Object already
line 18 is transform.parent
you are not assigning a parent in your Instantiate call
so what do I change it too?
the bullets hava no parent, do them needs parent? or can be gameobject directly under the scene?
either assign a parent in the Instantiate call by literally just adding transform as the fourth parameter or use some other way to determine the direction. such as passing the direction to the bullet when you spawn it
hello everyone I am fairly new to this world, I have this problem that I can't solve, it gives me the error : NullReferenceException: Object reference not set to an instance of an object
Tire.<Update>g__NewMethod|6_0 () (at Assets/Scripts/Tire.cs:29)
Tire.Update () (at Assets/Scripts/Tire.cs:25)
Seems like a basic NullReferenceException .
Either script1 or script1.bulloni is null
if you want i can show you the other script
Not really necessary
so what i can do
Figure out which of those things is null and fix it
the script is public, you dont need get component to assign it
what do you mean, sorry for these questions but really I'm going crazy
just drag and drop it in the inspector
Debug.Log is the first step to take
To figure out which thing is null
How can i make my raycast hit take the first hit only ? like i have a platform under the ground, the hit will take that coordonates and not the ground itself
Like on this scene, the raycast will not care about the little platform on top of the ground
I'll explain what I need this script for, I need to remove 5 bolts via VR to a wheel and after I remove these bolts I reactivate the rigidbody and the interactable grab, doing as you said of course it happens that as soon as I remove one of them already it reactivates the wheel
and it makes this
Does it have a collider? Is the raycast using any layer mask and is the platform on an included layer?
I don't think you can play an audio clip like that.
There is probably no such method.
And you're probably getting errors.
What can I do then?
all layers on default, not using any layer mask and yes ground has mesh collider, and the other platforms have box colliders
Then it's probably an issue with your code, rather than the raycasts. How do you confirm whether they hit the platform or not?
when i debug the hit, it detects both objects (ground and cube/sphere), but doesnt take count of others that the ground
Are you using RaycastAll? Why?
No just Raycast
Just raycast only hits one object. The first one it encounters.
hmm i see
maybe bc i raycast downward
thats why spherecast were better !!
but spherecasts makes my bug through ground sometimes
Draw debug rays. It's not quite clear where the origin of the rays is and what direction they have.
the origin is the tip of my legs
the end
and direction is -transform.up
i was using sphere cast, but it makes me bug
That's probably the issue. Raycasts that start within a collider, wouldn't detect it.
yeah...
so its just a raycast probleme now, its better i like it
with spherecasts :
What I'd do, is raycast from the joint down towards the tip, instead from the tip of the leg.
Do know that spherecasts ignore a collider if they start from inside that collider
Like if the initial position of the sphere already overlaps something, it wont detect it
Solvable with OverlapSphere or CheckSphere, at least.
Video looks like theres more issues tho
Help
Stop crossposting.
Check the guidelines on asking questions here:
#854851968446365696
I followed this, yet it still does not work: https://docs.unity3d.com/2017.3/Documentation/ScriptReference/AudioSource.PlayOneShot.html
"AudioSource".PlayXXXXX
I have an audioclip
Hi, I want to make it so that a prefab instantiates at the spot of a gameobject
its nearly working but I need to convert the gameobject into a vector somehow
You can't convert a GameObject into a Vector. However you can use the GameObject's transform.position
yep, thats exactly what I needed
thanks
?
You need an audio source for an audio clip
Unity is a pain in the ass
And this channel is dead
means it doesnt exist
AudioSource is a component you can add to a gameobject
add it there and you can assign a AudioClip and modify audio settings
I have added it
Exactly what I have done and yet it does not work
did you reference it
probably that the AudioSource has no AudioClip attached
In my inspector, the audio source has the audio clip
but playoneshot takes audioclip as on of its argument, so what you pass into it
have you check if it is null before you pass into palyoneshot?
well its obviously null
Instead of playing 20 questions, just show your code. It's a waste of time to claim you've done it all right.
I think I fixed it
Probably better ask in #🖱️┃input-system
Whats the vibe on the performance of something like a Physics.OverlapBox?
i se i didnt know there was a channel for that thank you very much
guys why
public void SetCameraX(float xAxis){
Cam.transform.rotation = Quaternion.Euler(Cam.transform.rotation.x , Cam.transform.rotation.y ,Cam.transform.rotation.z) ;}
setting the rotation to 0,0,0?, shouldnt it be the same as it was before
dont mind the random argument
It... Takes CPU time...🤷♂️
Because transform.rotation is a quaternion, yet you try to use it as Euler angles.
idk just wanted a like "its probably not going to be a problem before almost anything else" to a "it's like using getcomponent a ton" type scale haha. i get its a vague question
It depends on many factors and your use case.
But generally it's fine to use just like get component.
theres too many angle systems.
There are no angle systems. There are rotation representations. And only 2.
Degrees and radians are basically the same. It's like meters and kilometers.
Quaternions and Euler angles are different.
agree to disagree , but yea theyre a unit
ig ill research more on to that then
thanks
Okay, my sound is still not playing but there are no warnings this time
degrees and radians just differ by a factor
Only errors?
they are effectively the same, except mixing them up will make your calculations totally wrong
Go through these steps to see if your issue is one of them.
It is not muted and volume is 1
Btw, my game audio works so footsteps can be heard
It just does not play sound when you collect the item
How many times ere you asked to show code or info on your setup? Or read the #854851968446365696 on asking questions?
I just want possible advice
I don't want to share my code
I made an audio source and dragged and dropped my sound
Does your camera have an audio listener?
I gave you a list of steps, if it's not a code problem then move to #💻┃unity-talk
@wintry quarry hey, we managed to fix the issue yesterday and just thought i'd let you know what caused it.
the problem was that our entire game was organized into empty header objects that were tagged EditorOnly. stuff like ----UI---- etc. this was for organisations sake and ended up being fine in editor. originally, objects weren't supposed to be children of these categories so the empties were marked as editorOnly to make that clearer. they were just supposed to be inbetween everything in the hierachy. later someone forgot this and made them all have children at some point. no error about this either, since it technically wasn't an error.
such a silly mistake lol.
Hellooo !
Quick question : I have this GameObject wich is where the player will shoot from and it's rotating to look at the mouse position, but I want it to rotate around the player. I want it's pivot point to be in the center of the player. How can I do that ?
Change the X value of pivot. It's displayed in the inspector
if the GameObject is a child of the player, you could set its transform.localPosition equal to either transform.up * someDistance or transform.right * someDistance, depending on how the rotation works.. someDistance would just be how far away you want it to be from the player
(I am assuming you mean you already have the rotation code working)
as in, the object is rotating properly but just not in the right position
Hm no my GameObject only has Transform and a script.
Normally your gameobject should have a Sprite renderer to display the sprite
There is no sprite that's why I was asking, it only tracks where the player will shoot from.
It's a child of the gameobject?
Yeah that works thanks !
make an empty GameObject called "Pivot" at the center of the player as a child of the player.
Make this thing a child of the Pivot at the appropriate offset
Rotate the pivot as needed
Yeah I thought that would work but it's using another game object whereas there are ways to do it with code only like Nephren told me
hey guys, I'm building an Android game, and I have Images that I call and display in runtime,how and when is the best place to store it so I can access it after I build?
wdym by "images that I call"?
what kind of access pattern are you requiring
if I use kinematicRigidBody.MovePosition(pos), is there any way to read that RB’s current targetting moveposition? Or do I just need to log it somewhere, and reset the log every frame?
Seems like you already have it in the pos variable
The Rigidbody doesn't expose it anywhere, no
that’s what I was getting at. ty
A list of image file names (png for ex), that I iterate through, and open the image file, and place it on an Image game object
Why not just a List<Sprite> (aka direct references to the assets)
why do they need to be image names?
ya that's what I mean, the problem now is how to store the images and get access to it after I build. (I can't access the asset folder after the build)
Why do you need to access the asset folder?
Look up the Unity Resources system
Again what's wrong with the direct references?
what kind of access pattern are you requiring
^ this is the question you really haven't answered
sorry I thought I answerd, I don't actully know all the access patterns, but what I'm tring to do is to open them like a file (File.readAllBytes)
Ngl, the more i check around here, the more i see even though these problems are easy to solve, most of the difficulty comes from how ur gonna explain it. 
Props to u guys ig. 
Hey, is there a way to write a binary number as a float not Int32 ?
I'm saying why are you trying to access them that way?
that doesn’t make sense
you could do (float)0b110 but idk why on earth you would
Alright 
And i don't know why you want to write a float input in binary either.
if you just want to set a constant 6f, just write 6f
you probably want to define a constant for that or something tho
Well, I wanted to express for example 1/4 as binary 0.01 so I expected something such as lineRenderer.widthMultiplier = 0b0.01; but that doesn't work
Why?
what's wrong with 1/4f or 0.25f?
idk, that what I thought it's the way to do, what is the best way that you think of ?
like
private const float DEFAULT_LINE_WIDTH_MULTIPLIER = 6f;
Directly reference the image as a Sprite wherever you need it
as I mentioned in my first response
That's the case where I know 0.25 is equal to binary 0.01, number such as 0.3 can't be expressed equally in binary, right? It's an irrational number?
0.3 is a rational number with an infinitely repeating binary representation
computers don’t use irrational numbers
the questions is, WHY do you want to write them as binary?
you are trying to solve a problem that does not exist
you don't need to read images via bytes to load them, you are in a game engine with a renderer and asset pipeline, you can just drag the images into your project and reference them using the Unity inspector
Alright...
since the binary representation of 0.3f is infinitely repeating why on earth would you want to represent it in binary?
Definition of irrational number is that it can't be expressed in fractions right? 
To not lose on precision
literally impossible
you can’t
changing the way you write the number doesn't help you at all in that regard
a float is a float
public class SceneManager : MonoBehaviour
{
public void LoadScene(string sceneName)
{
SceneManager.LoadScene(sceneName);
}
}
what's wrong?
!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 named your class SceneManager
At what point should I stop in this video so I know I have learned enough CSharp for Unity https://youtu.be/M5ugY7fWydE?si=9J4CeU9Wfn71IOaw
Ask me Anything Anytime on Twitter: https://x.com/NewThinkTank
In this C# Full Course I provide the most complete tutorial on C# all in one huge 9 Hour course! I cover not only the core C# language, but also provide numerous examples on how to use them to make real applications. At the end of the course we make a database management system from...
right at the very end, and then you still don't know enough
Different video to what i watched.
how could I refrence them without the inspector?
it wouldn't be enough?
i feel like I can’t describe more about the precision thing without horrendously confusing the man
what video did you watch?
why dont you want to use the inspector?
It will take you months to become semi proficient, and years to master it
and thats assuming you are actively trying to learn basically the whole time lol
Using one of:
- Addressables
- Resources
- StreamingAssets
cause I want to generate them automaticly based on the level,
ok thx 💙
like... you generate them while the game is playing?
you should describe what you ar trying to make
Heeelp 
code: https://gdl.space/ukigomofuh.cs
problem: https://youtu.be/GUZe9NG8pvk
USE them not generate
Until you know classes, generics, and read docs and de-compiled library, that should be a point where you can rely less on lengthy tutorials like those and learn more by experience and reading text.
I didn't even know abstraction when i started on unity. I would say i got the bare minimum for self learning. 
then why did you say generate, haha
Either use debug logs or step through the code with a breakpoint to see what cells were found(if any) and whether the conditions to destroy them are satisfied.
anyways, you can still use the inspector to reference the images... even if you assign them to each level at runtime
Ahhh I see, the bare minimum is up to classes and generics?
I've already "debugged" it like this. Everything is located but Destroy(cell.gameObject); it doesn't seem to work, even Log("cell.name") shows everything correctly
My biggest problem with these vids though I have a bad attention span so idk how anyone watches these head on
How exactly did you debug?
I guess. 
You can google what's boxing and stack/heap allocation someday.
Feel free to deviate tbh.
As long as you try some quick examples on what you learned that's well and good.
Also, the logic of the deleting method really doesn't make sense.
Okay. Why did you remove that from the code that you shared? And what does is it output to the console when you test?
@queen adder This is the one that i watched. 
https://www.youtube.com/watch?v=wxznTygnRfQ
C# tutorial beginners full course (C# for Unity)
#C# #tutorial #Unity
⭐️Time Stamps⭐️
#1 (00:00:00) C# tutorial for beginners
#2 (00:06:30) output 💬
#3 (00:10:48) variables ✖️
#4 (00:19:32) constants π
#5 (00:20:35) type casting 💱
#6 (00:27:49) user input ⌨️
#7 (00:31:24) arithmetic operators 🧮
#8 (00:35:54) Math class 📏
#9 (0...
It shows the name (or id) of the cell, after which it should be deleted
If it logs, then it does destroy whatever object has that cell component. If the thing that you're expecting isn't destroyed, then that object is not cell
comment out Destroy and change the log to: Debug.Log(cell.name, cell.gameObject);.
Then when the message is printed in the console, click it and look at what object is highlighted.
that's what I need, so that a random cell with the desired id is deleted
And it does. The question is wether it's the object you expect to be destroyed.
I'm trying to make a game that generates blocks that fall and inside them is an image, and you have to choose the right answer for each block, It's like a teaching game, to teach you English.
so it will be an image falling and you choose the responding word for it, so the block should be generated on runtime, my problem is I want an optimal solution to reference the images, and put it in the block
After these actions, it did not delete but added. I will figure out why this is so
Nothing in this function could possibly be "adding" anything. If anything is adding a cell, it's not this code
I understand that.
Do this:
#💻┃code-beginner message
Click on the log, see what highlights
Then that's the reason probably. When one was destroyed another one was added.
Yes
If you log something in that new object's awake or OnEnable, you might see what spawns it in the stack trace.
!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.
Okay, so what in the holy hell am I doing wrong here? The camera just isn't moving to where it supposed to be (stays static in the scene). My Target is an Empty just in front of my object. It looks at it fine, but the position of the camera isn't changing at all.
public Transform target;
public float smoothSpeed = 0.125f;
public Vector3 offset;
void FixedUpdate()
{
Vector3 desiredPosition = target.position + offset;
Vector3 smoothedPosition = Vector3.Lerp(transform.position, desiredPosition, smoothSpeed);
transform.position = smoothedPosition;
transform.LookAt(target);
}
which object is this script attached to?
The Camera.
you sure smoothSpeed is properly set in the inspector.. ?
Show the inspector
Show the inspector of the object this is attached to
public variables with an initial value in code is a common problem here, it will just use whatever was serialized in the inspector
Hello! I have a function that activates an animation when I click on an object. The problem is I can't re-activate it because it stays activated even after the animation has finished. How do I re-activate it?
I've tried adjusting the smoothtime to lower and higher values, the camera just doesn't move to the rear of the ship when it rotates (it's like it's using world coords.
- Instead of using
GameObjectjust drag in theAnimatordirectly - Instead of toggling an animator component on or off, you should set a parameter on it to transition between states.
https://learn.unity.com/tutorial/animator-controllers
An Animator Controller is a Unity asset that controls the logic of an animated GameObject. Within the Animator Controller there are States and Sub-State Machines that are linked together via Transitions. States are the representation of animation clips in the Animator. Transitions direct the flow of an animation from one State to another. In thi...
well.. it is
It is using world coords
using world coords
You have nothing in your code that uses local
localPosition is the position of the transform relative to its parent, position is the world position
You're moving to the position that is 30 units behind the object in world space
that's not the problem here though, because everything in the script is using world coords, which should be fine I would imagine
If you want this thing to stay a fixed distance behind the object as it rotates, you should probably just use Cinemachine that does all that for you
oh well, if your ship rotates it would be a problem
I tried changing it to localPosition, and the camera went batshit nuts and caused unity to error out because it went out of bounds or something.
thing is, this is the code for pretty much ever single camera follow script I've seen.
Yeah that's not what you should be doing either
It's the code for every simple camera follow script you've ever seen
Yeah, but even this isn't following. lol.
you would have to use the target's local position as the desired position too, because it is also a child (on the same level of hierarchy)
It is following
if you wanted to switch to local position
all .position would have to become .localPosition
The problem is that the animator is on another object, so just dragging in the animator doesn't work. But thanks for the link!
Yes it does
@slender sinew Nope, that causes Unity to completely wig out.
can you show that code?
gimme a sec
Change the variable type to Animator and drag in the other object
It being on a different object changes nothing
I believe I tried that before but I guess I did something wrong then
Is piskel a good pixel art creation tool ?
It's ok
Sorry if this is of topic
sokay, think I got it figured. Thanks for the input fellas.
why doesnt the if statement work in this code
!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.
And the if statement does work. If the code inside it doesn't run, then other doesn't have the tag "walkFinish"
How do I rotate something around one axis with Mouse Input?
Also, when checking tags, you should use CompareTag, not ==
https://docs.unity3d.com/ScriptReference/Component.CompareTag.html
I've read through the tutorial but I don't understand how I execute the animation without doing what I already am doing?
im making a DDR style game mechanic but I'm having an issue where sometimes when the note collider is intersecting the collider that the player is meant to activate, it just passes through instead of registering it as hit. Does anyone here have experience with that type of thing?
Make an animation state that plays the animation you want, make a transition to it that depends on a parameter, toggle the parameter in code
If it's moving by rigidbody, there should be a dropdown where you can change "Collision Detection" to "Continuous"
I've changed it to continuous and tried out all the other collision detection methods but the problem still persists
How do I decide between float int bool and trigger?
How do you decide when making a variable if it should be a float, int, or bool? (Trigger is just a bool that auto-resets itself after use)
im wondering if maybe it could be because of the script that I use to move the cubes downwards, though I don't think it should be breaking the collision detection
float fallSpeed = 1.5f;
private void Update()
{
transform.position += Vector3.down * fallSpeed * Time.deltaTime;
}```
Yeah that's teleportation
Teleportation does not collide with anything
yeah what's the difference between them?
MovePosition on the rigidbody instead
One is a float, one is an int, one is a bool, and one is a bool that automatically sets itself to false after you use it
Lol I dont know what neither of those are. What, are they just random names that dont mean anything?
Then you should not be coding yet. You need to learn the basics of C# before you actually try to implement anything.
Look at the intro to C# in the pins
float is a number with decimal point
int is a whole number
bool is true/false
and what digiholic said
So what you're saying is my teacher should not be teaching? lol
If this is a class I'm guessing you should have paid attention on the first day of class
Because this is day one stuff
day 2 to be generous, day 1 is installing the ide 😄
If you don't know what int, float, and bool are, you are not ready to be implementing anything. You should be barely at "Hello world"
I've been paying 100% attention. I'm one of the most attentive in class. I guarantee you she just sucks then
we went straight into it on day one
how are you even programming without knowing what a bool is 
I don't even know
Debug.Log ("Detected");
cowText.text = "Press E to interact";
ani.SetBool ("Detected", true);
if (other.gameObject.CompareTag("walkFinish")){
Debug.Log ("colided");
walk = false;
TutStart ();
}
}```
she just teaches us functions and makes us copy them
why isnt the collider working
Does "Detected" print in the console
no it doesnt
The Three Commandments of OnTriggerEnter2D:
- Thou Shalt have a 2D Collider on each object
- Thou Shalt tick
isTriggeron at least one of them - Thou Shalt have a 2D Rigidbody on at least one of them
3 thats the issue
@teal viper Thank you for pushing me in the right direction. I fixed my problem
I've changed the script to use movetowards and its working a little better, but sometimes the colliders will still pass through, not sure why
current collision settings are set to extrapolate and continuous detection
Use continous on the rigidbody
oh nvm
is your object really fast?
like could it pass before a next physics tick?
Show the updated code
i am using an ontriggerstay to check for the collider though
Then better check for enter
float fallSpeed = 4f;
Rigidbody rb;
private void Start()
{
rb = GetComponent<Rigidbody>();
}
private void Update()
{
rb.MovePosition(transform.position + Vector3.down * Time.deltaTime * fallSpeed);
}```
Serialize the rigidbody and fill it in inspector btw
wont help your problem but just a general thing
that wont work for the ddr because it only does a check the second the collider enters the other collider, i need it to continuously check which object is inside the collider so the player can press a button and it gets destroyed no matter if its 10, 20 or 50% through the collider
can you fill me in what ddr means?
oh yeah i know that, just didnt know the abbreviation
ah
can you check if Enter works as expected though?
sure
as expected, I have to press the button at the exact frame it enters the collider
otherwise it wont be registered again and will just pass through
I mean just if it detects the enter 100% of the time
and just doesnt detect the stay 100% of the time
Technically you could do a HashSet which stores all objects that triggered enter and removes all that triggered leave, destroy all elements of HashSet on pressing the button
worth a try
Hi, i have an issue on my script and I wonder if someone can help me in a call ?
Which is better? To destroy a gameobject or to set active to false when you pick it up?
Or does it not matter?
is it a lot of objects or just a few?
if its just a few then you might be better off setting active to false, in case you ever find a need to reactivate it
Nice help
I guess it matters if you later want to do something with it. Deactivate if you want to enable it back and use later, destroy if it's not going to appear in the game ever again

Thanks I worked hard on it
Just ask your question
Oh, alright. Thank you
Also, my sound does not seem to be working when I pick the item up
If you plan to reuse it set it inactive
This method contains reference to the triggering object. If that object has a sound component attached then probably yeah
Ok sorry for all the images, i just script a program to switch weapon in my game and it return me this error
There is my script :https://gdl.space/benelomepe.cs
Looks like your code is expecting an Animator, but you've got a legacy Animation component on your object. You should use an Animator
An Animator Controller is a Unity asset that controls the logic of an animated GameObject. Within the Animator Controller there are States and Sub-State Machines that are linked together via Transitions. States are the representation of animation clips in the Animator. Transitions direct the flow of an animation from one State to another. In thi...
Ok thanks I will try to do it 👌
See how easy it is to get a question answered when you actually ask one instead of expecting someone to jump into DMs with zero information as to what the problem is
Yeah sorry, I didn't really understand your site. I'm still learning English
Anyone know how I could merge 2 healthbars into one? I have my P2 attached to my P1 and they should count as a single entity, but they have completely different functions and so therefore they aren't really one thing, but they should still share HP. (the comments at the top are kinda me thinking if I should make 2 separate scrits, but idk if that would work so am looking for a solution here 😵💫 )
!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.
If they should share health, then the Health object should not be on each player, but on some sort of shared object they both reference
Yeah but they lose health once they are hit, and I can't really make such a custom collider.
If the Health object exists in some neutral place, instead of getting it from the player you hit, reference it directly on the enemies and have them deal damage to the shared health system when they hit the player
Or make a new script that handles the shared health that your current Health script references instead of having its own copy of
This should have nothing to do with the healthbars. The healthbars should strictly exist to display a health value
Hy Guys, I have a problem in an online game where robots are constantly on the server and players can enter and interact with them, but I have a bug that if the server is empty and someone enters, the objects in the robots' hands get bugged, can someone get me help or have an idea of what causes this??
Your UI shouldn't be running your game
way too vague. do you have any information about in what way the objects are getting "bugged"?
we also don't know what multiplayer framework you're using, how holding objects works, etc.
what debugging steps have you taken so far?
My collision will not work and I am super confused
So I have followed steps in the course I am doing giving rigidbody to my character and making sure they both have box colliders
And there is some collision but if I just hold forward I go through it
How do you move the character
wsad
sounds like you're moving your character by teleporting it with the Transform rather than actually moving with the Rigidbody.
not asking what buttons you use, asking what method you're using in the code to move it
thats not movement
transform.Translate (xValue, 0, zValue);
yep so
There we go
that's teleportation
teleportation does not respect colliders
Right because we are just teleporting forward frame by frame
if you are using a rigidbody, you need to let the rigidbody handle things
otherwise it's like getting on a bus and then trying to steer it yourself
it's gonna crash
cna anyone help me please, for some reason it fully works exept the x position is like off by 0.4 / 5
how do I let rigid body handle
go to the scene view and select the object you're moving. make sure you are in "pivot", not "center" mode. press W to show the movement arrow gizmos.
do they appear where you expect them to?
look up the movement methods for Rigidbody component
Here is an example of what could be wrong. The cube isn't actually positioned correctly.
it was alr on pivot ill check the other thing
yea the other thing is good
AudioSource.PlayClipAtPoint(PickUpSound, transform.position); does not work
it is perfectly in the middle with same rotation as urs
are you sure game view is not just muted?
So do I just need to use another way to make my cube move?
a very easy thing to miss
I can hear other sounds
rb.MovePosition will move the rigidbody to a new position
This will do so in a way that respects colliders, assuming the rigidbody isn't kinematic
and then do I just use that instad of the teleportation methods?
Right.
rb.position = ... will teleport the rigidbody to a new position, without trying to move it from point A to point B
which you might sometimes want
So I would get rid of the transform.translate thing?
Yes.
You'll want to compute the new position based on the distance you want to move
probably rb.position + moveAmount
is it better tu use transform.position than rb.position???
you tried playing same sound in other audio sources ?
neither
then what???
rb.moveposition, addforce, .velocity
how does that make it better?
I literally started Unity yesterday i am confuse
because they're methods made specifically to move by physics
.velocity is kinda forcing it but stil respect physics
what if i dont want it to move with phyiscs (i dont in this current scenario)
then you don't get accurate collisions, interactions physics
I am not sure how to impliment rb.position + moveAmount into my code
id recomend completeing a course/tutoiral if youve only been doing it for 1 day
you can just replace your .translate code with .velocity tbh
I got told I needed an AudioSource but I actually did not
Can i modify this object's rotation somehow?
told by whom ? PlayAtPosition creates its own audiosource
anyone know how to make this work properly it works but for some reason its ofsetted on the x
i need a hand on something, so i have five bolts of a wheel and each of them has an equal script that defines, when the drill is near unscrew the bolt. i need to make the wheel understand that when all five bolts are unscrewed i can detach it. now it detaches but right after i remove one
why are u using indecies on locations
I'm doing a really large course but he just introduced collision and it wasnt working form e
weird
ok
Someone already gave you something to look for. Check to make sure your objects pivot is actually where you want it to be
I used PlayClipAtPoint
idk i thought it was the easiest way
ive alr responded to that and it is
"Transform' does not contain a definition for 'velocity' and no accessible extension method 'velocity' accepting a first argument of type 'Transform' could be found (are you missing a using directive or an assembly reference?)"
error message
no you have to use the rigidbody not the transform
Would anyone please take a look at this and see where I'm going wrong? Pulling my hair out at the moment.
In the first image, the little solar panels are supposed to be pointing in the direction of the sun (Just on the Y axis for now), but the angle is way way off and I can't understand why. (Second image is to illustrate their 'neutral' position).
[SerializeField] Transform sun;
// Update is called once per frame
void Update()
{
Vector3 targetDir = sun.position - transform.position;
transform.rotation = Quaternion.Euler(0f, targetDir.y, 0f);
}
private void OnValidate()
{
Vector3 targetDir = sun.position - transform.position;
transform.rotation = Quaternion.Euler(0f, targetDir.y, 0f);
}
we've been talking about rigidbody this whole time
its transform
no capital T
How do I trigger particles?
... dont respond if u cant help as it wastes both of ours time
https://docs.unity3d.com/ScriptReference/Rigidbody-velocity.html
if your rigidbody is kinematic use rb.MovePosition
Don't ask a question again if someone is currently in the process of answering it
no one is but ill note that for futture if that ever happens
I have two particle effects that I downloaded from the assets store. I want to trigger them on command
... dont respond if u cant help as it wastes both yours time
Someone?
i helped there is no captial T
whats the question?
i don't get iit
I'm using Photon Fusion, I believe the problem is that when the server is empty the Object stops being a parent of the hand and I don't know how to save this even with an empty server
you're wrong.
the method is on Transform class and it doesn't help the main issue they had.
Keep a count of how many bolts have been removed and how many you need to remove. Whenever you remove a bolt, add one to the first number. If the amount removed is equal to the amount required, detach the wheel
No, you said nonsense that had nothing to do with the question. There is no velocity property on transform
well i font use capital T and mine works so unless my entire vs has been hacked i think im right
Show your code that uses transform.velocity and doesn't thrown an error
i dont use velocity but yes
I'm using Photon Fusion, I believe the problem is that when the server is empty the Object stops being a parent of the hand and I don't know how to save this even with an empty server I tried to reset the rigidbody of the objects when the server is empty but it didn't work, I'm looking for a way to keep this Parent inside Photon Fusion
Okay so why did you say using lower-case transform would suddenly magically make transform.velocity work
i dont have time to argue so ill be afk
that's literally what you replied to
.Play or .Emit
"just not working" is not helpful
guess we just throw our hands up and say "iss broke" 🤷♂️
the problem is I am not familar enough with everything to know what I need to change
In the course I am watching the teleporting works somewhat fine but it won't work at all for me
did you look at the example ?
you're working with components.
Transform is a comeponent, Rigidbody is a component
all your doing is changing using methods on transform to methods on rigidbody
right so I tried replacing transform to rigidbody
"Non-invocable member 'Rigidbody.velocity' cannot be used like a method."
what don't you show what you did instead
Please? I'm going bald. lmao
these messages don't help , we need to see what you typed
we sent you twice the docs to .velocity
!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 need a reference to your rigidbody component.
how do you see it written in example
Simply typing Rigidbody means nothing to the code, it doesn't know what rigidbody you're referring to.
!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
that too 😄
I tried to understand them
honestly as a begginer I must agree that the docs are really hard to learn from
I found a lot more luck with youtube videos
its a lack of understanding how basic c# works
nothing much to do with unity
knowing Class vs Instance differences
A direction and a rotation angle are not the same thing. You're rotating about the Y axis based on an amount from a normalized vector, meaning you will be rotating horizontally by less than one degree
any API is difficult to understand without basic language knowledge
@polar acorn Of course is. lol. Well don't I now feel like a complete muppet. I really should stop doing this coding milarky at the end of the day. lol.
"Import Error Code:(4)
Message: Build asset version error: assets/mover.cs in SourceAssetDB has modification time of '2023-10-19T16:55:26.4573584Z' while content on disk has modification time of '2023-10-19T16:55:31.8948717Z'"
Unity docs are some of the best tbh.
Now Im getting that
dont worry about that warning rn
Im not trying to argue with yall
Im just saying that I was in a similiar situation to Lilith
yeah but saying "finding luck on youtube" is bad advice
I started it and it spammed the console with a million errors telling me rb variable has not been assigned
Well, has it been assigned?
The velocity.
What Rigidbody do you want to move
im not giving advice, Im just sharing my experience
you obviously know a lot more then me
So assign it to that
Read the docs.
drag the rb on your character and drop into the variable apperas in the inspector
Then I wish them the best of luck.
Gregg already has rigid body component
you can assign other components in inspector through the same way (including your script)
How do I make sure the particles doesn't play on start?
uncheck Play On Awake or w/e is called
Starts Awake
forgot what is called
am too stupid
Lazy*
stupid
So assign your variable to that
So I assign my variable to gregg?
To gregg's rigidbody
where is that?
if that is the one you want to use
on the main component
all the way at the bottom
Play On Awake
how would I write that in code
you wouldn't
you would drag the object into the variable on your script
thanks!
anything public will appear inside the inspector as a field
so for the variable would I write public Gregg =
