#💻┃code-beginner
1 messages · Page 194 of 1
Yeah, that's fair.
I made it sound like there was no reason to, I was more curious why in this case it was needed
Thanks for the reply Sexy. I'm still learning how unity works with situations with a canvas and grids for in this case an inventory system.
That being said, still lot to learn - I wouldn't really call it hyper specific - I'd honestly think this would be a pretty common occurrence really. two grids on the same canvas (plus or minus a few other components) but will most likely have these components from what I've seen)
The ask is can a gamepad cursor travel between the two grids automatically or as you and I think are saying is that input has to be reviewed when you reach a border and move to the next grid if performed - again, or, does the native grid component just know what grids are on screen at any given moment
hope that makes it a bit clearer than mud 🙂
cache?
The default navigation mode is "Automatic"
It tries to find a Selectable object in the direction you navigate
You can test it out using the arrow keys on your keyboard.
It often works well, but it can have weird hangups
Grid component only organises it's children in grid like structure, it doesn't care what platform you are making the game for, where the mouse is or where the gamepad cursor is. So if you want your gamepad cursor to interact with grid in any way, you have to code it
You may wind up needing to manually define navigations for each selectable element
Gameobject instance = Instantiate
Just save it as a variable
cool - thanks guys!
"Explicit" mode lets you assign a Selectable for each of the four cardinal directions
Oh wow this is new for me
Is it for controllers only or works for PC too?
well nevermind i dont know caching or using stuff later ill look into it later
first one is his second is mine what am I doing wrong?
I'm off to watching some tutorials then, I never knew what the yellow arrow lines were in UI xD
go read the documentation I just linked first
and the rest of the UI documentation, tbh
I have no clue what the problem is
what is the problem?
How do you resolve this error, any ideas?
Are you attempting to convert a project from the built in render pipeline to the HDRP?
...you have both URP and HDRP packages installed
yes
is there a particular reason you have both
he didn't get this pop up what did I do wrong?https://www.youtube.com/watch?v=JIsRH7hXpDQ timestamp 2:00
This tutorial series teaches you how to take 360 images and make a virtual tour with points of interest in unity.
Follow me on twitter https://twitter.com/JamesDestined
Follow me on instagram https://www.instagram.com/artbydestined/
Buy my pieces on redbubble http://DestinedArt.redbubble.com
Any comments or questions welcome. Enjoy the video!
oh yeah, this error message is a really confusing one
I was downloading assets to decorate the terrain
I remember encountering it before, but I forget what causes it
Did you recompile the script as I asked you to 5 times already
you can't just install a bunch of render pipelines and use them all at once
No, I mean the instantiate line. Line 23 would be
variable = Instantiate
Instantiate returns a reference to the thing you instantiated
Also your script reads new behaviour script, but I don't see it in assets
my advice, in no particular order:
- this isn't a code question. ask it in #💻┃unity-talk
- don't install the URP and HDRP packages together; that makes no sense
- don't randomly try to change render pipelines just because one asset you downloaded requires them
👍
yes that fixed my problem
Whats wrong here? Everything works except the timeScale shit, why?
what makes you say the time scale isn't working
That when i press Escape the game is still running behind the PauseMenu canvas
and are you doing anything that actually uses the time scale?
I bet they have no idea what Time.timeScale does
Its suposed to stop the game clock isnt it?
"the game clock?? "
ill check it out
Guys, is there any way to fix this? I want my bullets to come out of the gun and after being fired to focus on the camera but not suddenly, but little by little they become centralized in the camera when fired, here is the code I use
Vector3 direction = (crosshair.transform.forward - bulletSpawn.transform.forward).normalized;
Rigidbody rb = bullet.GetComponent<Rigidbody>();
if (rb != null)
{
rb.velocity = direction * shootForce;
}
the result (they don't even shoot) =
When timeScale is set to zero your application acts as if paused if all your functions** are frame rate independent**. Negative values are ignored.
Why isnt the drawer opening?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DrawOpen_D1 : MonoBehaviour, IInteractable
{
public bool isOpen = true;
public void Interact()
{
Debug.Log("open");
transform.Translate(0, 0, -2);
if (isOpen == true)
{
transform.Translate(0, 0, 2);
Debug.Log("close");
isOpen = false;
}
}
// Update is called once per frame
void Update()
{
}
}
!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.
mate
The scale at which time passes.
This can be used for slow motion effects or to speed up your application. When timeScale is 1.0, time passes as fast as real time. When timeScale is 0.5 time passes 2x slower than realtime.
When timeScale is set to zero your application acts as if paused if all your functions are frame rate independent.
I just read it
But the code is suposed to work like that isnt it?
hi! im making a tower defense game and i wanted to show the range of a tower to the player. how would i go on about doing that? is there a way to change the radius of an object through code?
considering what the docs says, what are you observing to see timescale has taken effect or not ?
yes ofc
two very different questions btw
not
what
Which item are you observing
post it properly or get no help, its pretty simple
really? how can i do that?
which part, you asked two different questions
and the standard answer to "Can it be done"
is usually Yes
oh i meant the changing radius part
well, what is radius in context of your object
my tower's range
@lost anvil its not diffcult, read the bot message it tells you how. I cannot read it properly on the phone
so you want to draw a circle that represents the range of the tower?
its not that deep but okay
objects don't really have a "radius". They have a position, rotation, and scale.
Do you want help or are you just here to be a contrarian?
dont be a jackass
<@&502884371011731486>
what u mean what item? like in the inspector? or in the camera? or what
which item that depends on time.scale are you observing to see if changes are working ?
you did yeah i didnt know i had to put my code or whatever a certain way and i didnt see the point of it
you dont see the point, but we do and thems is the rules
yeah because im new chill out lad
why would you make it diffcult to read the code if you want help on it?
yes, although like you mentioned im not sure how to do it when objects have only a rotation pos and scale
thats counter intuitive and waste of time rn
!mute @lost anvil 2880 take a couple of days to grow up and stop being an edgelord or don't come back at all
keraunos5900 was muted.
well, you could make an object that shows up with a radius of 1 when its scale is [1,1,1]
then just scale it
Define what radius is through code ?
Unity won't have exactly what you want built-in
you need to use the systems it provides to create new systems
okay ill try this, thank you!
the pause menu i guess, when i press ESC its shows up and all that works but the game is still running behind it, like it lets me move the camera and i can still hear the sound of it
If it's a 2D game, a SpriteRenderer should do the trick
how are you moving the camera?
let me make a video to show u
ill be back in a minute
Here, i now think it actually stops the game but i thought it didnt because of the sound and the camera (sorry xd), how can i fix that?
that doesnt answer What i originally asked
how (script) are you moving the camera?
unless you're using * Time.deltaTime
typically a camera look system doesn't have anything that pauses on timescale
the camera and movement is from a free asset i took from the store
its too big to be sending ss
then to "pause" you have to do it like everyone else does it
disable the scripts
ill try
learn events and make an event
{
if (rayHit.collider.GetComponent<EnemyHealth>().enabled)
{
gameObject.GetComponent<EnemyHealth>().Damage(damage);
}```
Is this the proper way to damage via a raycast?
no
flimsy af
noted, what would you recommend
TryGetComponent for the rayHit
and cache the EnemyHealth on itself
if (Physics.Raycast(mainCamera.transform.position, direction, out rayHit, range, whatIsEnemy))
{
if (rayHit.collider.TryGetComponent(out EnemyHealth enemyHealth))
{
enemyHealth.Damage();
}
}``` 🙂
if (rayHit.collider.TryGetComponent(out enemyHealth))
{
enemyHealth.Damage(damage);
}```
moreso this then?
exactly
but u dont need EnemyHealth enemyHealth = null;
you can just put it on same line like my example
sick thanks again
so ive got a ragdol made up of 3d objects and connnected by configured joints i have a script so whenever something is grabbed by the hands it holds the object but if moving too fast the object goes inbetween the body parts and the character breaks
try maybe enable Continuous collision checking
@rich adder I did it, but now i have a problem with the cursor, like when i close the menu its suposed to go away but when i click it doesnt
How can I make array [3]'s spawn time 5? (int animalnumber= Random.Range(0, animalprefabs.lenght)
where do i do that
on the rigidbody
show current code, also when you press escape and mouse appears its usually editor only that stays unless you click back in the window
the same way you said
!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.
!screenshots
No
Be mindful, if someone requests your code as text, don't send a screenshot!
whats that?
use your eyes and read it
also nothing in your code tells the cursor to "go away"
thats a good point
Cursor.visible = isPaused;
Cursor.lockState = isPaused? CursorLockMode.None : CursorLockMode.Locked```
You have an extra }
yeah i mean except for that
the logic is it good
im sure it can be more optimized tho
yes for example avoiding repetition of similiar code

using Coroutines much nicer and modular in comparison of Invoke or InvokeRepeating
since you cannot pass arguments to method, in Unity's Invoke/Invoke repeat
how come I can't add the montreal botanical garden in winter image that I put in the sprits folder onto the Source Image?
probably because its not a Sprite
also not a code question
Texture and Sprite are not the same
neither was the snow trees but it worked
select snowtrees and show inspector
Then select botanical and show inspector
I can tell from here its not a sprite
the others were, how much you want to bet 😏
im pretty sure the issue is in my grab script but im not sure whats wrong about it
am i allowed to send vids to show issues?
Yeah. .mp4 will embed it
Texture type wasn't set to Sprite (2D and UI) for botanical
i thought it was mp4 my bad
thats literally what i just fucking said
problem solved
Have you done this yet?
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
core.AddForce(new Vector3(context.action.ReadValue<Vector2>().x, 0, context.action.ReadValue<Vector2>().y) * 500, ForceMode.Force);
how do i alter this so that the movement is relative to the camera? i tried a couple things but they didn't work very well
transform.TransformDirection with the cameras transform
converts it from world space to local space
im using configurable joints to make ragdol movement but whenever something is grabbed the hand goes further then it should how do i limit that?
what do you mean? i don't understand what you mean by "converts it from world space to local space"
World space is the "normal" space, where position Y is up and negative Z is back
Local space is what you use when you move an object, where the blue arrow is the positive Z direction
Your inputs are in world space but need to be converted to the camera's local space
Local +Z is the direction you are facing
oh yeah sry
No, you're correct, Bobbo
how do i word this...
in local space, your forward vector never changes. It's always (0, 0, 1)
i don't know in what context i put "tranform.transformdirection"
I had it as positive Y is forward which is obv wrong
Ah, you changed it :p
In world space, your forward vector is constantly changing
where do i throw in "transform.transformdirection"
Transform.TransformDirection takes you from local space to world space
If you want to know which world-space direction is "right" for you, transform Vector3.right into world space
Transform the input vector to the cameras local space
_cameraTransform.Transfor....
Quick question, I have an issue that I never understood : I have a character and a checkbox to know if it's on ground, and if it is on ground I set my gravity velocity to 0, but when my program runs, my character sinks into the ground ; despite 0 force being applied, why so ?
for example make
SpawnRandomAnimal
get an index
so if you want a specific animal just pass the index
void Method()
{
SpawnAnimal(3)//spawn horse
SpawnAnimal(Random.Range(0, animalNumber.Length)); //random animal
}
void SpawnAnimal(int animalNumber)
{
var selectAnimalPrefab = animalPrefabs[animalNumber];
Vector3 spawnPosition = new Vector3(Random.Range(-spawnRangeX, spawnRangeX), 0, spawnPositionZ);
var instantiateAnimals = Instantiate(selectAnimalPrefab, spawnPosition, selectAnimalPrefab.transform.rotation);
}```
ofc you gotta play around with the spawn time stuff in a coroutine too
how can I instantiate at the position of an object which isn't the object the script is inside of
Get a reference to that other object and use its position
That's all the detail I can give without more detail from you
it's the second parameter that needs to change right
lookup the manual of Object.Instantiate
dont guess
transform.position is the position of the transform the script is attached to. You need to get the transform of the object or position you want to instantiate it at, and use that instead
We need more info. Is the character a rigidbody or a kinematic body? Does the player and the ground have a collider?
if your character is on ground and is using velocity i am assuming it has a rigidbody? If so it should not sink into the ground no matter your set gravity scale,. Unless you are doing really high values
Yes, exactly
…so is it a rigidbody?
Yes a kinematic body
you cannot assign velocity or use forces on a kinematic rigidbody. how are you actually moving it
With transform.position
oof
How are you checking if it’s on the ground?
Maybe it's not the best option I dunno
It is not
Definitely not
With a checkbox
What do you mean a checkbox? How are you checking? What code are you running to see if it’s on the ground?
That doesn't make sense as a response to the question
Unless you have a super custom movement system, just use default rigidbody
pretty sure they mean Physics.CheckBox
So with CheckBox() not a checkbox
Alright there’s a bigger underlying issue here
I’d reccomend remaking your movement system unless you’ve spent a ton of time on it
how do I make the spawnanimal variable in void(method) run in void spawnanimal?
i didn't know if i should put it on wich channel but help
i am trying to make the unity window change places
but only the canvas does
for my html site
The thing is I had first a Character controller and i used .Move(), and now I'm trying to switch to a RigidBody, but the only provided method that could replace it that I found was rigidbody.velocity. But know I'm using a kinematic, so the only thing I found was directly moving the transfotm
ok
What kind of movement system do you want?
Just a simple platform we movement?
You mean it's a bad strategy ?
here
Yes, directly modifying position for your movement is a bad idea
Rigidbody.MovePosition()
But it teleports my object to the vector coordinates, or I did it bad
wdym
It does, and so does setting transform.position
But MovePosition is what you use with kinematic rigidbodies
Wait what
Will do
Okay gotta check things in my code, thanks
Both moveposition and transform.translate or transform.position = will teleport the player
But moving the transform while using a rigidbody makes them fight and is not a good idea
If you have a rigidbody, use the rigidbody
Ive been trying to implement the example you wrote into my code. you wrote spawnanimal(3) but i need to make spawnanimal variable actually spawn animals so Ill have to copy and paste the code in spawnanimal codeblock
or if theres a way I can make it access the codeblock below
So you would be doing that in html or javascript or whatever you are using for the layout of your site, not from unity itself
yes
spawnanimal is not a variable, its a method
Not really
just do it however it works and is easier for you, dont worry about "optimizing " at this point in time
It shouldn't actually have anything to do with unity at all
It would be the same as moving an image or video lower
Wdym spawn animal variable?
yeah. I couldnt implement your way of code into mine anyway. I guess we will add DLSS and FSR to my game and call it a day
here
this spawnAnimal doesnt do anything
i have to make it spawn animals
you're changing SpawnRandomAnimal to SpawnAnimal
nothing more @timid saffron
But the thing is I was gradually changing my transform position with a +=, but I can't do this with MovePosition(), that why I was saying that the last teleports the player and not the first one
Well what code is within the SpawnAnimal method?
You can absolutely gradually change the position with moveposition
The docs have good example code
Okay gotta check em thx
Assuming they didn't modify it
Well it should work then, if that’s your code
Hello guys, i'm making a modular ship building system but i'm stuck.
newAttachment.ConnectTo(attachment);
UpdateAttachmentVisibility();
The ConnectTo function sets the positions of the attachments together, and the update attachment visibility function loops through all attachments and make them visible if they are available. However the updateattachmentvisibility function runs before the connection, causing some weird glitches. How can i make the update attachment always run after the connection is done
wait i think im doing it
So you want to wait until all the attatchements are done and then run UpdateAttatchmentVisibility once afterwards?
It doesn't run before the connection. ConnectTo runs first.
Perhaps you have code that runs in Start or Update
and that needs to execute before UpdateAttachmentVisibility runs?
But when i turn this into a coroutine and add a 1 second delay between them, they work fine
yeah, sounds like you have code in Start that needs to execute first
public void AttachmentClicked(Attachment attachment)
{
ShipModule selectedModule = shipModules[selectedModuleIndex];
GameObject moduleObject = Instantiate(selectedModule.prefab);
Attachment newAttachment = moduleObject.GetComponentInChildren<Attachment>();
// StartCoroutine(AttachmentClickCoroutine(newAttachment, attachment));
newAttachment.ConnectTo(attachment);
UpdateAttachmentVisibility();
print("Clicked on attachment");
}```
This runs when the user clicks on an attachment
I want to wait until this line finishes completely
newAttachment.ConnectTo(attachment);
Yes, and that already happens
Your code doesn't run out of order
Programming would be a nightmare if line 2 could run before line 1
But why does it work when i put a 1 second delay between them
Because you probably have code that runs in Start
and that needs to execute before UpdateAttachmentVisibility works properly
Async await coming to make your life a living hell:
Start runs on the first frame after something is created
await still enforces an order :p
I can't tell you anything more specific without seeing code, but that's the most plausible explanation
ok yeah ive been trying for like half an hour but i really still can't figure out what this means
The attachment script doesnt have a start function, it only has awake which sets the variables
i wouldn't word it that way
transform the input vector from the camera's local space to world space
When you push the W key, you want to move forwards
But what is forwards?
If you just move in the world forward direction, then you move in the same direction no matter how the camera is rotated
You want to move in the forward direction of the camera
And the attachments visibilities get set as the new created part is at the center of the world
Share the relevant scipts. !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.
Vector3 moveDesire = new Vector3(moveInput.x, 0, moveInput.y);
We want moveDesire to be from the POV of the camera.
And we want to convert it into a world-space direction
We accomplish that with _theCamera.transform.TransformDirection(moveDesire);
i get all of this
i understand local and global and all that
then what's the problem?
the problem is i don't understand how to do that
how do i make it from global to local
idk what i do to turn my code into that code
i'm not sure you understand it
since you just said "global to local"
which is precisely backwards
all you need to do to go from local space to world space is to use transform.TransformDirection
it takes a local-space vector and returns a world-space vector
that's it
If your camera is rotated 90 degrees to the right, TransformDirection will turn a forward vector into a right vector
Attachment.cs
BuildManager.cs
If it's rotated 180 degrees to the right, it turns a forward vector into a backward vector
but where? where do i use "transform.transformdirection"
core.AddForce(new Vector3(context.action.ReadValue<Vector2>().x, 0, context.action.ReadValue<Vector2>().y) * 100, ForceMode.Force);
within this
to replace new vector3?
break that line up. it's a long mess
create a vector first
call it moveVector or something
Who calls Initiate on the Attachment class?
It looks like that assigns spriteRenderer and coll
you didn't actually say what the problem was
does it involve those two variables?
no one
wait
do i just literally replace new Vector3 with camerTran.TransformDirection
lmfao
i just did that and i think it worked
well, no, you pass the vector to TransformDirection
look at line 114, when i use it with a coroutine with 1 second delay between functions, it works fine. but if i dont do it, the attachments visibiliets at the center become weird, but it gets fixed when i reopen the build mode
I don't know what "become weird" means
it acts like if the new placed object was at world center
Do these objects have rigidbodies on them?
no
yeah getting there
hmm, I'd have to stare at this a bit longer to offer more suggestions.
it says that these 3 attachments collided with the new created object
what
When a Transform component changes, any Rigidbody or Collider on that Transform or its children may need to be repositioned, rotated or scaled depending on the change to the Transform. Use this function to flush those changes to the physics engine manually.
Yeah, that's almost certainly the problem.
The physics system doesn't realize you've moved the colliders until the next physics update
ehh. 45 minutes of work will do this max
So the collider positions are bogus
actually if i didnt misunderstand your code it would have taken much less
It thought they were still at the world origin, or wherever they happened to start out at
does it matter if i use physics2d or 3d
Yes, it does
I do 3D almost exclusively, so I always forget about 2D...
The other method wouldn't help
I could've given a better example but was on mobile so was hard to type it out all 🙂
no the example was fine 🙂 i didnt know the thing you write after void could be used in other voids
And sometimes you're halfway through typing up some code and someone else posts the same thing in half the time
thats why I was confuesd
those are methods not voids
void is a return type. They are not thingd
Think of methods as just a keyword that replaces the code
It is the EXACT SAME as writing the stuff inside the method where you call it
yeah I dont know their names fully so I just call them thing thanks 🙂
But I got the logic
so thanks
Next is replacing Invoke repeating with Coroutines 🙂
so the Time Between spawns can be also changed on the fly
How can I move an object relative to it's parent?
I have an object. When it's collided with, I want it to move to the top of it's parent object
I know how to parent it via script, but not exactly sure how to move it
transform.localPosition
parenting already moves it relative to parent tho
But right now, the object basically just sticks to it's parent wherever they collide, but I want the object to basically teleport above it's parent when they collide
What if I want it to be above? 0, 10, 0?
object.SetParent(theParent)
object.localPosition = new Vector3(0, 10, 0)
yes
0,0,0 is the paren't position
5,0,0 is 5 on the x relative to parent position
etc
time stamp 8:19 what does he mean by the opposite? https://www.youtube.com/watch?v=JIsRH7hXpDQ
This tutorial series teaches you how to take 360 images and make a virtual tour with points of interest in unity.
Follow me on twitter https://twitter.com/JamesDestined
Follow me on instagram https://www.instagram.com/artbydestined/
Buy my pieces on redbubble http://DestinedArt.redbubble.com
Any comments or questions welcome. Enjoy the video!
8:19 there is no mention of "opposite"
8:27
they are doing the Opposite of setting it active..
pretty self explanitory
i want to animate the legs on a ragdoll character. im pretty sure if i animate the legs in any way, even when i move to an animation not involving the legs, the legs will become rigid and move towards position and rotation (0,0,0). is there a way around this?
the errors seem to be cut off
0 errors
so I tried coroutines (first time) as navarone suggested but this coroutine doesnt seem to work
my goal was to set horsespawn time to 10
just call the method you want directly
they have no errors
those are IDE messages / suggestions
How
is the logic correct? @rich adder
the same way you called other methods?
well where does SpawnHorse Exist?
yeah the method right under it
please tell me you did not write that from gpt
here
I get method name expected error
show the code
you named your local variable the same as your method
so it puts using the local variable priority
and you cannot run a string like a method xD
generally people use lowercase first letter for local variables
also why is the var even called SpawnHorse
get rid of the useless parameter lol
its not being used, but also where its fed in, you have SpawnHorse2 and SpawnRandomAnimal, with the function not using the data at all
btw this will spawn the Same animal for both routines
it doesn work anyway it constantly spawn horses now
exactly
i think coroutines are big brain for me right now i should probably look into them later
if you want them to be separate coroutines pass in a Func/Action
would just make so you can pass in the function for it to call
or use a enum and a switch
well I dont know enum or switch or func action so this probably is too much for me right now Im deleting the part with coroutines for now and return to Invokerepeaters
they mean make One for Horse only and one for the rest
no this is making it worse
and why is SpawnHorse2 still there lol
private void Start()
{
StartCoroutine(SpawnCoroutine(SpawnHorse, slowerTimerSpawnInterval));
StartCoroutine(SpawnCoroutine(SpawnRandomAnimal, timerSpawnInterval));
}
IEnumerator SpawnCoroutine(Action theMethod, float CoroutineInterval)
{
while (true)
{
theMethod();
yield return new WaitForSeconds(CoroutineInterval);
}
}```
When I run SceneManager.LoadScene(SceneManager.GetActiveScene().name);
it keeps buffering and doesn’t reload, does anyone know why?
wdym buffering?
Like it shows it’s loading but it says app not responding
hard to say, maybe You might have an inifite loop somewhere.
does the loaded scene also call to load the same scene
or contain code with a infinite loop
Ahh yes good question, maybe its recursively calling
It runs using
button.onClick.AddListener(Restart); in Update()
Yeah
yeah its because you added Restart to the button many many many times
esp without cleaning up
so when the button is clicked its calling Restart thosands of times
Alr
Thanks
Kk
or the above, is a good option since that will disable the button for you if you disable the object
Ok ty
how do I do that?
Ive been searching but cant find an instance where they transform an object in another object's script
transform means an objects values in world space. position rotation and scale. To get a reference to another objects transform, a beginner way is to make a public variable called "public Transform otherTransform". Now in the editor, you can select which transform is to be targeted by this variable. Then you can use otherTransform.position
ohh okay
thanks ill try that
Hello! I have a really weird problem, I'm making a small multiplayer game with joystick controls and all that, I'm using netcode for gameobjects, and my player is like being overridden by the second player, do anyone know about some good unity 3d mobile tutorials? or where could I get someone to help me review my project?
If you are still stuck, this explains what I mean with a video https://www.youtube.com/watch?v=kYm-xjeXkvY
This is a c# unity tutorial focusing on a problem I had as a beginner that involves referencing objects and accessing there scripts.
yellow book free online
https://www.robmiles.com/c-yellow-book/
also fundamentals of computer programming with c#
word of advice, you should gain more unity experience before diving head first into Multiplayer
why is it though that you can't just write gameobject.transform.position?
or gameobject.position
position is not a property of a gameobject, it is a property of a transform
also definitely doesn't belong in #💻┃code-beginner thats a bit of an oxymoron
you can write gameobject.transform.position in a script, itll target the gameobject the script is attached to.
so would it be gameobject.transform.position
where could I go?
but instead of gameobject the other object that I actually want to move
yes
Okay, thanks! I just need a little help in the right direction
why is this coroutineInterval isnt being used
so you have two ways here. Either you make a reference to your gameobject and then use getcomponent transform to get its transform. OR you directly reference the transform
okay i get it thanks
So would it be canvasImage.setInactive(true)?

Where do I put it? cuz as you can see in the video he doesn't show where he's putting it is it directly after public void HideImage()?
put it wherever you want it to execute
dont blidnly cope/paste code you dont understand
I fixed it by manually adding 10f here
for now it works
I dont know why it wont use coroutineInterval I write in pharantesis but it works for now
pass the variable coroutineInterval would work
you got 2 things with the same name again
for a function paramater coroutineInterval
and a field with the same name
yield return new WaitForSeconds(coroutineInternal); would do that then delete the
private float coroutineInternal = 10f; you got at the top
A good habit could be adding _ before private variables
well in this case it is just duplicate
i use the _ convention but also just dont end up with duplication of names like that because its confusing
yup
I need an alternative text engine/solution that can draw the entire text as 1 draw call instead of each letter individually, which seems to be the way Textmeshpro works. So if you have overlapping letters and fade out, theres an undesired alpha overlap. Don’t have this issue in Godot or html5 canvas.
The text outline is applied to each character individually so the alpha overlap is really visible when your text is 50% transparent in a canvas group
TMP is not doing each character as a draw call
but it is doing a quad for each character
do you even know how draw calls works?
if there would be 1 draw call per 1 character
most of bigger unit games will be unplayable even in 30fps lol
am assuminmg there problem is with how TMP builds its mesh to draw
i have tried for 2 years to fix this
and just draw the whole thing as one
i think the whole system has to be changed or rewrite shaders
this is most simple repro i can do in a new project
just change character spacing to a negative value and change opacity of canvasgroup
you might be able to fix this with the blending mode in the shader
in Godot you can just make a node with a canvaslayer and everything under it will fade as one like a flattened png
dont know without testing
i tried that
changing the blend mode broke antialiasing
and made the text choppy
but it did fix the issue
chances are what Godot is doing writing all the SDFS in into one buffer then putting that on geo and running the shader on it
while unity is putting each char onto a quad in a mesh, then running the shader on it
yes thats probably what godot is doing
and i need something like that in Unity
another solution i saw was to use RenderTexture
but it complicates things so much
when i have lots of texts that i'm trying to animate, position, and scale for different aspect ratios
Why do some tutorial videos for 2D unity set mouse position as a vector3 then set the z to 10?
I know the camera's original z is 10 but why should the mouse be
im not talking specifically about godots text implementation , because im not sure
all i know is godot 4 added canvaslayer where EVERYTHING under the node is like 1 flat png
i didn't know it would be so hard to do in Unity
i can do it in html5 canvas too
with pixi.js
i considered buying Super Text Mesh asset for $95 but i dont know if it has the same problem, there's no free trial
unity is 3d at its heart no matter what, so issue comes from that since it wants to approach everything with meshes and shaders
😦
if the chances to blending mode could not do it
then its a hard thing to fix if wanted for all text
sicne more or less comes down to rendering texture to a buffer instead of using it directly
Note: The CanvasGroup uses a custom shader to read from the backbuffer to draw its children. Assigning a Material to the CanvasGroup overrides the builtin shader. To duplicate the behavior of the builtin shader in a custom Shader use the following:
idk
then rendering that buffer out as a image later
i really need a solution
Blend One OneMinusSrcAlpha
i dont even know which combo would do it
The faulty code will be underlined red, in your code editor directly. If that's not the case, configure it using one of the links below
!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
i forgot which i install visual studio code from
this is with blend off
how can i check
If it's Visual Studio Code, then you need to click the 3rd link
And do not post the same question in multiple channels
i tried all of these:
Blend SrcAlpha OneMinusSrcAlpha // Traditional transparency
Blend One OneMinusSrcAlpha // Premultiplied transparency
Blend One One // Additive
Blend OneMinusDstColor One // Soft additive
Blend DstColor Zero // Multiplicative
Blend DstColor SrcColor // 2x multiplicative
``` no work
yea i just posted it again because somebody said they would help me in that channel so i posted it there again so they wouldn't have to switch back and forth
post this here before but deleted it cause i thought i solved it
i didnt solve it i still cant figure this out
!code
!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
one thing is obvious, movespeed and runspeed end up being exactly the same
The second if statement is weird also, "if sprinting then sprinting = true"? Did you mean if (!isSprinting)?
If you're not sprinting, then start sprinting
Makes more sense
im curious why thats the case
I'm currently trying to use RigidBody.MovePosition(), but it almost doesn't move when I start playing. I then saw that I had to put it in FixedUpdate(), but do I need to put the line of code that set the velocity, that is in my Update ? Because I just moved the MovePosition, but it doesn't seem to work
one botton sets _moveSpeed to _runSpeed the other sets _runSpeed to _moveSpeed
so they will become the exacty same value on both vars
i know. im just trying to understand wwhy that guy did something like that
you really need to learn to read code
they should just have a _currentSpeed
that they set to either move or run speed as needed
im adding a current speed now
I read it 😦 i was trying to say im curious as to why that guys movespd is equal to ruunspeed
not about u
as i just realized what was happening
then you read it but did not understand it
It's probably a mistake. The second one should have been something like _moveSpeed = _walkSpeed; to return back to walking speed
+1 on following naming conventions though :)
because you know movespeed is generally like for normal moviing and runspeed is well its supposed to be more than movespeed i was cuiriouus why they were equal
because the code made them equal even i the starting values were not
Again, it's a mistake. moveSpeed here refers to the current moving speed, not some preset speed
implemented a walkspeed to update the movespeed that fixed it
thanks guys 🙂
can you share it?
Is it better to serialize private variables than just making them public?
its litterally making a walk speed serialzefield then just replace what code was there
well do you want it public or not
its a nice option since it lets you expose and save it in the inspector but not let other objects change it
Hows it going, I want to learn how to code c# but dont know where to start. Any Ideas
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
why my tracer isnt rendering? 😭 Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2f, Screen.height / 2f, 0f)); RaycastHit hit; if (Physics.Raycast(ray, out hit, shootRange)) { if (hit.collider) { LineRenderer tracer = Instantiate(tracerPrefab, muzzle.position, gunHolder.rotation); tracer.SetPosition(0, muzzle.position); tracer.SetPosition(1, hit.point); Destroy(tracer.gameObject, tracerDuration); } if (hit.collider.CompareTag("Toilet")) { hit.collider.GetComponent<ToiletBehaviour>().hitsReceived++; } }
Are you sure if this code is even running
Any idea why my AI is not moving on a NavMesh that was generated during runtime using NavMeshSurface? It's showing an error "GetRemainingDistance" can only be called on an active agent that has been placed on a NavMesh.", My AI IS ON THE NAVMESH and when i bake it normally not at runtime then it works.
Instantiate(this) will create an exact copy right? So I should use a prefab to instantiate a "base" object, right?
Because right now, using Instantiate(this), it seems to be in the exact same state as the copied object
its not a exact copy
but very close in most case, but non serilzied stuff just starts at its defualt values
It will clone the object this script is on
Ok
@shell sorrel i fixed the earlier text issue with BlendOp Max
it was that simple
actually it only works for white text
Why do I get this random Unity exception?
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Graphs.Edge.WakeUp () (at <871096295abe423b9c0af38ec6fe4bf2>:0)
UnityEditor.Graphs.Graph.DoWakeUpEdges (System.Collections.Generic.List`1[T] inEdges, System.Collections.Generic.List`1[T] ok, System.Collections.Generic.List`1[T] error, System.Boolean inEdgesUsedToBeValid) (at <871096295abe423b9c0af38ec6fe4bf2>:0)
UnityEditor.Graphs.Graph.WakeUpEdges (System.Boolean clearSlotEdges) (at <871096295abe423b9c0af38ec6fe4bf2>:0)
UnityEditor.Graphs.Graph.WakeUp (System.Boolean force) (at <871096295abe423b9c0af38ec6fe4bf2>:0)
UnityEditor.Graphs.Graph.WakeUp () (at <871096295abe423b9c0af38ec6fe4bf2>:0)
UnityEditor.Graphs.Graph.OnEnable () (at <871096295abe423b9c0af38ec6fe4bf2>:0)
Unity Editor bug
Ok
Ok, this may seem smth extremely simple but I'm freaking out since hours on this problem : I had a CharacterController component that I used to move my chracter. To manipulate more freely the hitbox of my character, I decided to switch to a RigidBody. I made all the necassary tweaks, except the most important : I can't succeed to replace the CharacterController.Move() function. I tried to use RigidBody.MovePosition or RigidBody.velocity =, but my character is extremely slow or just freaks out. Thanks for the help 🙏
if its slow it probably needs alot more force to move it.. its not going to have the same kind of values the character controller was using
they'll usually be higher (without a multiplier of some sort)
There is no direct replacement to the Move function. You'll need to rework the way you calculate your movement to actually use physics.
One uses rigid body physics and the other use some custom game physics
Also some unadviced me to change directly transform.position, so I should use MovePositon ?
Modifying position of a transform would be teleporting
I could work wit += no
Adding BlendOp Max to the TMP shader fixed my issue with additive overlapping text alpha, but it doesnt work for black text, the black text just becomes invisible!
I tried and it seemed ok
+= to what?
Like gradually incrementing the positon by some direction vectors
and you don't understand why?
Teleporting?
why do I have so many errors? I got them after making this
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MediaImage : MonoBehaviour
{
public GameObject canvasImage;
public TourManager tourManager;
// Start is called before the first frame update
void Start()
{
canvasImage.SetActive(false);
}
// Update is called once per frame
void Update()
{
(canvasImage.activeSelf && Input.GetKeyUp(KeyCode.Escape))
{
HideImage();
}
}
public void ShowImage()
{
canvasImage.SetActive(true);
}
public void HideImage()
{
canvasImage.SetActive(false);
yes
i do understand why, because its no longer the max value color
of #FFF
and becomes #000
but this is bad, i need it to work for black text too..
It's no longer the max color of the background vs what's rendering
Teleporting will not comply with the interpolation settings. Move position takes it into account but it's for kinematic rigid bodies.
its against the rules to commission people in this server, right?
well this sucks, i solved the issue but not for black text lol
The bad solution is to just have another variant with min blend lol
this is what it looks like with min blend
i need to invert it
i think
whats transparent should be black
Ah, it mins the alpha channel, weird
i struggled with this issue for over a year
well the BlendOp would depend on what the Blend line is also doing
and what is this line of code meant to be
And the bottom of the code is missing, somehow
perhaps offscreen, but yes it seems like it
no clue what blend line means
anybody used Super text mesh from the asset store before and know if it has same issue?
The canvas would have to be showing and the Escape key would have to be pressed
would have to be? There's no logic on that line, just two statements that evaluate to a boolean
and what do you see missing in that line
Is it a ;?
stop guessing, and look at it
There's no ;
Yes
No
no
But he doesn't have one in the tutorial
wht
Please, what type of statement is that line trying to be
oh brackets
its many things we are working on the statement first
If you have a tutorial just compare the line character by character
it'll be obvious as hell
yeah no you're right, i was just correcting myself saying the line won't need a ; even in ots correct form cause of the brackets
I did this is what he has
The tutorial wrote it differently than you did
if
Comparing it character by character on that line should fail at the very first character
Where's digi, I think this is the third time his counter will go up from the same person
And look at the left of the line YOU wrote
They didn't make a claim that it wasn't the tutorial though
so it's not counter-worthy
Ah, I read this
#💻┃code-beginner message
As saying they had the same thing as what the tutorial had
fixed it now I still have this error
Yes, that was only one of the multiple errors
Have you done this yet? !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
If not, STOP and do it
I'm still counting it
"I did it exactly like the tutorial so why does theirs work and mine doesn't" counter:
Number of times it wasn't exactly like the tutorial: 146
Number of times it was exactly like the tutorial: 5
Number of times the code literally did not exist: 1
2022-07-19 to 2024-2-11
was told this yesterday and the day before
you need the basics of programming first, before trying to push through a tutorial
fixed it
are you sure about that?
Do not
- Respond with new issues you have not researched.
We can't just post every little issue you have one after the other. Go away and look at it for a single minute
I need a ; at the end
you are just guessing, and not understanding or even comparing it with the code from the tutorial
Please stop ignoring people. Go do the learn course. Don't come back and keep guessing
You're about to at least be muted, maybe banned, by vertx for ignoring what they told you
once you get some of the basics of C# under your belt, these are the kinda issues you will see and know how to fix instantly
like it will be impossible to no see them
It should not take ten people five days to tell you how to type the same things as a tutorial. This is no longer asking for help this is crowdsourcing your job to random people on the internet
how do i remove tmp essentials that i imported to a new project?
You delete it from your project, it's just in your Assets folder
what's the difference between his code?
scroll down
Hey guys, Im playing around with adding relative force to an object and it would be super helpful if I could show the object transform, is that possible?
and mine?
look at how methods end normally, look at how yours ends
I can't that from the video
also just look at the intro stuff in the learning content
well apply your brain
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
It's pretty obvious that the second function is not ending the same way as the first one, suggesting the file isn't finished yet
It's almost like all functions have the same structure that is required to make code compile so there's no point in showing the end of a file and you're supposed to actually know what you are doing enough to know that
Another way you ask it is, what's the difference between ShowImage() which has no issues, and HideImage(), which has an issue? The main problem is some tutorials on YouTube are sketchy and you really should go through a curated place like unity learn.
A second hint is what you see when you hover over the red error
the curly brace and the end
Give it a try!
I did and still get an error
Can I see the code?
But yes, a good rule to follow - for every open brace you should see a closed brace.
you are missing a other brace
the one for closing the class
And don't forget to hit save after you write it.
Shockingly the same information in the resource I just linked
yes
Stop. Ignoring. People.
Do. The. Learn. Course
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Like damn, this is beyond ridiculous
This is not a forum for people to do the work for you
you didn't close the function
Hello all, I have a rigidbody that is flying across the world by itself
Not sure why
heres the code
Im not giving it any inout when I play the scene
and its flying east
Like a burd
Its off east for winter
If i comment out the euler angles line then it is okay
Im guessing thats the issue but im new to coding and wondering how to properly use it
I cant wrap my head around the documentation page so I would appreciate some help
!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.
Lik e this?
transform.eulerAngles = new Vector3(0f, 0f, 0f);
I got it
This is the line that causes the bug
what is the intent of that line @hazy crypt
if its a rigidbody it has buttons for freezing rotations on it for you
Is there a reason you're not just using rigidbody constraints to lock rotation?
I would like to learn how transform.eulerangles works
Probably best to learn while not driving a dynamic rigidbody
I want to use this to add a rotation to my player character, I just wanted to start experimenting with a line that did nothing and add inouts to it
if that makes sense
dynamic physics bodies shouldn't be manipulated directly via their transforms
I had read that somewhere but im unsure how to achieve my goal i i dont
the rigid body will have methods for rotating it adding forces like torqe to it
Turn based game. Battles / fights are happening in the BattleScene.scene
There are many different lists, including each team/side list, and so on. After battle there's transfer to outer world scene.
Question: Do I have to clear the lists after battle end? Does this information make some informative trash?
For example I have the list of all the buffs each unit has in the battle. What happens if I don't clear the list after battle? That list is not on some scriptable object. Just List<Buffs> buffs = new ();
Or are all the lists get basically trunkated automatically and this data is not gettign stored anywhere after scene exit?
Yes im just not sure which to use to achieve the correct output
Ive tried adding torque and adding force, both relative and not and I ant seem to get it
I worked on a game years ago but I did everything except the ode and Id like to revive the project solo
heres the game
Follow the development progress here:
https://www.reddit.com/r/icosgame/
https://twitter.com/icosgame
https://discord.io/icosphere
This is the movement Im tying to reccreate
The ball only rolls forward/backward, but rotates the whole character left and right to face a new diection
This looks fun 🙂 Sorry I have no idea how to help you, just giving you a shoutout )
well where does the data exist like on a object in the scene?
it's like gO to which script is attached. Each time battle starts, new lists are created. And I kinda started wondering what happens with lists from previous battles.
oh wait I can freexe some planes o rotation
well if you are unloading the scene, then the lists are gone if htey were on objects of that scene
great, thank you
how can you stop a function from running more than once
have a bool you set true the first time the function runs
then return early out of the function if that bool is true
if (hasRun) return;
Hi everyone, I have a prefab object that needs to create a reference to a different script upon being created in my scene. I'm trying to use FindObjectOfType however it is always returning null.
Line of code to find object: manager = FindObjectOfType<RoomPicker>();
RoomPicker is the script thats on an empty object in my scene (it is enabled)
I've been trying to debug this for the last 4 hours and I'm not sure what to try next
the code should work considering RoomPicker is present, like you said..
my guess w/o seeing any code is a race condition.. your'e using the manager before it gets a chance to find the object..
perhaps all this codes trying to run in a single frame.. or perhaps the code should be run somewhere other than where it currently is.. like OnEnable vs Start.. hard to say w/o context
give me 1 second to put it into a paste bin, the find object is in the scripts start() function
When you load a lot of objects when a Scene starts, all the awake calls will be guaranteed be run before a single start call ( though the order is not guaranteed at all). So this is when you initialize script variables. Then all the Starts are called before any Update is. This is where you get hooks into other scripts (Since they should all have initialized themselves in their own Awakes).
Now when you instantiate an object mid scene, Awake is called directly after the object instantiates, then the rest of your code continues from the instantiate line. Start is guaranteed to be called before the *NEXT* frame's update, but not necessarily anytime during this one.
that is good to know, but I also just found my problem
I had it as start() when it need to be Start()
well. that should have gave you a compile error
or atleast a console error.. saying it wasnt used
but yea capital unity functions
it was only giving an error when I tried to click the button and it didn't have access to the other script
Start() Awake() Update() etc
thank you very much for the help (what make me double check was you typing Start in your first message)
i tend to try to remember Awake -> Set up Self
Start -> Set up Others
that way you avoid some of those times
I got this error after writing a variable in wrong then correcting it afterwards?
show code
Remove the System.Numerics namespace. . .
or that
It's unneeded . . .
it wasn't there
but I found an issue in the code which fixed it anyways
not sure why it had an effect on every single vector though
The error states that System.Numerics was in the code . . .
What was the issue?
didn't return any values from a function
unless system.numerics was added and removed automatically it isn't there
!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.
Hey there, it's me again with another question:
I'm working on a VR Scene where I have multiple windows that I'm interacting with, to close them.
After closing them I want to send a message to my script where it say's that i closed ALL windows. However I'm unsure how to track the statues of multiple windows without creating a check for every single one of them.
Do I create an Array and check if any of these windows are still not interacted with? Or what's the correct approach
Code here: https://gdl.space/utihiyetag.cs
Thanks in advance for the help
!cs
Join the C# Discord server, a programming server aimed at coders discussing everything related to C# (CSharp) and .NET. https://discord.com/invite/csharp
You can just create a counter with an initial value of how many opened windows there are. Once you close a window, decrease that value, and if you open a window - increase it. Every time you close a window just check if the counter reached 0 and if it does then do whatever should happen then.
oh wait that actually makes so much sense 
lines
var source = sourceObj.gameObject.GetComponent<UnitAttributes>().Stats;
and
var source = sourceObj.GetComponent<UnitAttributes>().Stats;
basically do the same, right? And yes, <UnitAttributes> is MonoBehaviour.
and sourceObj is another script (mono behaviour class) attached to that gameObject
how can i make parts of my ui fade all as 1 object
like a flattened png does when you change transparency
loop
Yes
i think u need rendertextures
no i need it to fade and not multiply alpha..
thank you
Dotween the alpha?
no
when i fade the canvasgroup with dotween, all the children fade separetly and it looks terrible
unity is the only engine ive used that does not have a simple solution for this
actually uhm is it ok if i dm you?
because i think it's actually more complex than anticipated/I'm not smart enough to fix this
everytime you open a window increment a int or add the window to a list
when you close one, subtract one, or remove it from the list, then return control when it reaches 0
It's a bit more complex than that I assume. Because I need to check first if the window is active or not and if it's not active then i have to add it into the list to check if it's interacted with
ok that sounds pretty simple though you can just maintian a list of them all and check for what ever you need to on it
A list? How do you mean that?
this line should instantiate 'weaponPrefab' at the position of 'SpawnPoint', right?
taking a look
it isn't though
why not
yeah just found out it wasn't set active
when it instantiates though it flies a bit up then freezes
hard to say without much detail 🤷♂️
Ok i am a bit overwhelmed by that
._.
besides the commenting, could anything in the code be the problem?
(not saying the commenting would be an issue)
ur trying to grab the rigidbody from the prefab reference
instead of grabbing it from the instantiated prefab.
(the one in the scene)
so should i save it as a variable THEN grab the rigidbody
A list is a very basic thing
pretty much yes
u want the rigidbody from the prefab clone (the one u spawn into the scene)
What I thought would work making a script for my windows that checks which status the window has (opened or closed).
And the only way to get all of them and check if they are all set to false (closed) is with a list?
imagine a box where you put all your stuff, but they are all the same thing
Like a box of fruits, you can only put Fruit inside the box @fickle stump
but how can I instantiate it and save the variable
if you have a list of windows to check their status yes
same way you assign any other variable
if the Size is fixed then Array works fine
eg. if you dont add or remove windows to list of mantained windows to check
and that would result in it being instantiated also?
like that?
Should probably learn the first basic collections if you intend on making a game
Array, List and Possibly a Dictionary.
very Important
GameObject newClone = Instantiate(groundSelectPrefab,hit.point,Quaternion.identity);
Rigidbody clonesRB = newClone.GetComponent<Rigidbody>();
clonesRB.AddForce(transform.forward * Mathf.Infinity,ForceMode.Impulse);```
ive never done it but i think you can just instantiate it as a rigidbody
if it has a rigidbody component.. could be wrong tho id have to try it real quick
Rigidbody clonesRB = Instantiate(groundSelectPrefab,hit.point,Quaternion.identity).GetComponent<Rigidbody>();
clonesRB.AddForce(transform.forward * Mathf.Infinity,ForceMode.Impulse);
why are you adding a force and using maths at the end
im pretty sure that works.. but its ugly.. theres probably a better way to do this even.. but thats the gist.. spawn it first.. then manipulate its specific components
just dummy code..
oh okay
doesnt mean anything other than u can use the rigidbody reference
clonesRB.isKinematic = true;
i wonder what would happen if u gave a rigidbody infinity force as an impulse 🤔 rofl
doesn't work for some reason?
whats the error say yea
u prob orgot ;
yeah fixed
I don't know why you're still here not posting actual errors
unsurprisingly you cannot
I spent like 20 minutes trying to get an error message out of you yesterday
me?
duh
yeah haven't built a habit of checking the console
why did we spend time configuring it if you're not gonna use it 
most compile errors the ide will know about and for runtime errors you need to check the console
i do use the ide but it just underlined in red
so assumed I had to find the issue myself
yes which is what you try to do before resorting to asking basic question ide answers lol
you do need to figure out why the error occurs.. some times it tells you str8 up whats wrong, other times it takes a google or two.. always useful regardless of which scenario
the ide catches stuff before u make it into unity.. unity will catch most of the rest.. (like the inspector/ scene/ type stuff)
is this not working because the instance is not instantiated yet, or because it's just flat out wrong?
the 'none gameobject' gets instantiated later
That's not how you write getcomponent
Only types go in the angle brackets, not variables or references or anything else
Would only work if WeaponSpawn was a namespace and weaponInstance was a class 😈
thats not how you access elements inside another script
. is the right operator to use , you're just using it wrong
sorry to ask this but it's just cause I can't access the project rn but could i instead write: weaponspawn = currentAmmo.getComponent<Weaponspawn>();
weaponinstance = weaponspawn.weaponinstance;
Sure, that sounds right. The GetComponent works at least. Assuming WeaponSpawn is a class name
and it is fine even if the instance is not in the game at the beginning of the run test?
what is currentAmmo
weird naming
You can just store it as WeaponSpawn so you don't need GetComponent
it is a code for a slingshot so the current ammo loaded onto the slingshot is currentammo
but its GameObject, thats weird name for a GameObject
not sure how id do that tbh
the same way you are storing GameObjects in the inspector
yes
when you have a field in the inspector of a certain compoent type, you can just drag in any GO that has that component on it
How do I prevent a Sprite from blocking OnMouseEnter?
the class is a type