#💻┃code-beginner
1 messages · Page 18 of 1
no, look to the right
yeah, that's your index, you can use that
you don't want to hardcode scene numbers
i dont under stand how to do it
did you read link what I sent ?
Well you can use [Scene] tag before an int so in the inspector it's easier to pick a scene
no don't just copy code willy nilly
😦
you have to understand that you have access to that list through buildIndex property
some thing like get active scene + 1
sure stuff like that
So look up how to get the active scene index
yup. its literally in the link as example code
that gives you the Scene
then you have access to other proprieties
like index , name etc.
i am so confused lmoa
look at this line
Debug.Log("Active Scene name is: " + scene.name + "\nActive Scene index: " + scene.buildIndex);
its literally in english
What do you want to get from the active scene
if you don't understand the string you might need to do some basic c# courses
to go to the next scene in the line
Get the current scene's build index and add to that. Then load the scene with that number
Okay, so what property do you want from the current scene to know what the next scene is
whats a proprety
how can i make it so that i the OnBeginDrag works on slots which are on different canvases?
https://hastebin.skyra.pw/gelonezibo.pgsql
the input and output slots on the right are slots which are on a different canvas
thats why OnBeginDrag is not being called
It works? How? 
Local Functions
its rare but they have been useful
I've never seen implementing a method inside another method
like doing something once etc
how can i send code here
!code
📃 Large Code Blocks
Large code blocks should be posted as 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 get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
its backticks @shadow flame
i have slots on a different canvas, and when i try to drag (OnBeginDrag) its not detecting them because there on a different canvas than this script is on and inventory slots are in, how do i go around it?
it was fine inside the if statement
but it should not be a function
also nice chat GPT code
obv its not teaching you fundamnetals of c#.. this will be more of a struggle
because you had a nested function
and arent calling LoadNext();
you have to remove the function inside a function
if statement isn't a function
first of all remove LoadNext from OnCollisionEnter2D
and then actually call the function
tbh if ur struggling with this u should learn the very basics of unity c#
Interesting
I'd like to find its usage though...
Thanks for sharing 
Now just CALL the function
ok good
LoadNext()
Where you want to do it
I personally used them myself more often doing Console apps , its been a while.. I'm sure if you look around some examples are therem the use cases are explained pretty much on the doc
ok one step closer.
Yeah, I need to read it all, thanks again!
now what?
make sure your player is tagged with Player and u have a collider on both
at least 1 rigidbody
Sorry to add on, but your nextSceneIndex at the top has nothing to do with the one in the LoadNext function. Whenever you write the type (int in this case) you are declaring a variable. It is a new and unrelated one.
It doesn't matter here, but this misconception may cause you confusion later
local variable will not affect something with the same name
can someone please help me with this?
they're different as far computer knows
where did you put this script?
and then this is like a military crate
it has its own canvas
thats why OnBeginDrag is not called
iirc OnDrag should be on the canvas, or of the elemnts you want
maybe theres like a setting in project settings for the OnBeginDrag to work on all canvases?
or like in the event system
You shouldn't make OnDrag be part of some type of Inventory manager
why not?
I wouldn't do it that way
because its already doing way too much in 1 script
your mixing inventory logic with UI movement /drag logic
i see what you mean
alright i'll put that in the cell script
but still
the OnBeginDrag is not detecting other canvases
the inventory manager?
using System;
using UnityEngine;
using UnityEngine.EventSystems;
public class InputManager : MonoBehaviour
{
[SerializeField] private Camera sceneCamera;
[SerializeField] private LayerMask placementLayerMask;
public event Action OnClicked, OnExit;
private Vector3 lastPosition;
private void Update()
{
if (Input.GetMouseButtonDown(0))
OnClicked?.Invoke();
if (Input.GetKeyDown(KeyCode.Escape))
OnExit?.Invoke();
}
public static bool IsPointerOverUI() => EventSystem.current.IsPointerOverGameObject();
public Vector3 GetSelectedPosition()
{
Vector3 mousePosition = Input.mousePosition;
mousePosition.z = sceneCamera.nearClipPlane;
Ray ray = sceneCamera.ScreenPointToRay(mousePosition);
if (Physics.Raycast(ray, out RaycastHit hit, 100, placementLayerMask))
{
lastPosition = hit.point;
}
return lastPosition;
}
}
if I don't build it, everything is displayed exactly, although this was not the case on a regular camera?
no the canvases
yeah
should the canvases have inventory manager?
each one
i think that would work
each one should be smaller managers of their own inventory/stack at very least
then communicate that to a bigger manager of stacks
think of it like if you disable something it should not break everything else
each part should be able to function independently without breaking
should i put the OnBeginDrag on my slot? and then communicate with my Inventory Manager?
that'd be the best option
i think
Where should I start more multiplayer matchmaking? i followed Code Monkeys video on Game server hosting(multiplay) and matchmaker but i don't know how to set up the code
advice on multiplayer. Don't make it one of your starter projects
you will just encounter pain
This isnt my starter project i just want to make a prototype for a different game that i have been work on for a little
but i don't know how to set up the code
sounds like this is one of your starter project
besides specific API stuff to Netcode everything else is normal coding you do in single player
If you feel the need to post the question in #💻┃code-beginner you should probably not be touching multiplayer with a ten-foot pole
Anyone know why my character like levitates when i attack sometimes? At end is a good example, happens sometimes when im just like on a weird surface also and just attacking, im guessing its my collision box but just wanna check
2x speed btw xD
is there a tutorial or anything
on how to make a 2d kinematic rigidbody (with movement, jumping, etc.)
could i do this?
just have the OnBeginDrag OnDrag etc on the slot
and then communicate with Inventory Manager?
it looks messy
wdym messy? also using events would be cleaner
what do you mean events
having a giant monolith of different systems is th messy one
I'm trying mate Inventories vary in complexities, I'm not even sure what you're going for exaclly
what is even the purpose of these cells
just drag and drop to work across different canvases
I get that but why all the drag and stuff from the cell itself
because when i do it inside Inventory Manager, it doesnt detect the slots
because there on different canvases
each like chest has its own canvas with slots
so when i had OnBeginDrag in inventory manager it only worked for the slots in the inventory
(slots attached to the canvas the inventory manager is on)
I get that but what are you struggling with
because i wanted to do it that way
handle everything inside Inventory Manager
but i dont know how
each slot has their own logic yes?
eg, if you drop items into it, should it stack
doesnt need to
shouldnt at least
i really want to handle the OnBeginDrag OnDrag and OnEndDrag in my inventory manager
but again OnBeginDrag wouldnt work this way
unless you can somehow in project settings make it so that it works on every ui element in the scene
🤷 I wouldn't know, My UI knoweldge only goes as far as card games
when i drop items it checks if there is a slot under your mouse
bro has messed up architecture he can keep pushing forward but a lot of his problems stem from the fact responsibilities are all over the place tbh
then what do i do
I use OnDrop method on the slot itslef 🤷
to see whats been dropped into it
then i wouldnt need the GetCellUnderMouse method?
I'm not saying thats how you should do it, just saying most of my logic is handled by the Slot class itself
since it deals with slot processing the item
maybe look at different inventory tutorials, see where they did something you can improve , make better version of combined knowledge
i already spent last 2 months working on the inventory
watched like all the tutorials
theres nothing left
well code mutates and adapts, refactoring is a thing
then u accumulated a lot of lessons to go bald and redo it the sooner the better imo
did that 3 times
well idk im on 3rd time too now with couple of main systems in my game and its getting cleaner every time lol
I bet some of mfs are the 10x devs and can do it right at first try but redoing it is like my main way to do things cause I see why current code sucks at the end
inventories are def the top furstrating / complex to work on imo
yea
alright im doing all my drag and drop logic inside the slot
OnBeginDrag /OnDrop probably
and end
why would you end drag a slot?
I have EndDrag on my card if its dropped somewhere besides a slot
it returns back to original slot/pos
Hey, how do I get the components parent name?
What do you mean "parent name"
any component on gameobject has a transform, that has a property for parent if thats what you want
Nvm i think i know what im doing ill update 1 sec
is a click drag and drop easier than actual dragging?
eh probably a question for UI/UX
prolly same just u start and end it diffrently
is there a tutorial or anything
on how to make a 2d kinematic rigidbody (with movement, jumping, etc.)
the internet has plenty
do you have any particular one in mind
so im attempting to make a gun stay on the screen but itll rotate with the player yet it wont like move from its current position if i look right/left it might change to be like in the middle of the screen
not really, there are too many tbh I dont work too much in 2D
video of issue
- script
which object is weapon parented to
https://hatebin.com/dzqemohmls (cam script)
https://hatebin.com/bjvjmttsod (player)
its on the player, but it acts the same for both of them
then are there any you know if that work in 3d?
shouldn't be too hard to adapt it to 2d
oh my
please don't do this
transform.rotation = new Quaternion(cam.transform.rotation.x, cam.transform.rotation.y, transform.rotation.z, transform.rotation.w);
use euler angles
also why is it rotating with cam on X
oh that was just a test to see how the gun would react
ok show hirerchy, also inspector for gun
k
the cubes just have a mesh filter + renderer
did u try comment this out activeGun.transform.position = transform.position + gunOffset;
oh wait
camera holder is not in the player?
all i did was comment this out so the x,y,z must have been getting set by that instead of the parent object
transform.Translate(transform.forward * speed * verticalInput * Time.deltaTime); is it transform.forward to go up in the x or Vector3.forward?
up in the x?
forward is blue = z
red is .right
Vector3 is in worldspace
I wouldnt use translate if you plan on using collisions
addforce to it
if you want physics
its a very very simple game
CC would suffice if you don't want gravity or physics reactions
alright
you just switch Translate for Move (ofc from CC component)
and its pretty much done
and add the component
alright
when use on on click in a button i can cant select a function whats happening?```cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SelectClass1 : MonoBehaviour
{
public int whatClass = 0;
public void ARClass()
{
whatClass = 1;
}
}```
will i need to replace all of my transform rotations and other stuff with controller.Move?
you are probably not selecting the script from a gameObject but the project folder
not necessary
currently the player no longer will rotate on the y from the camera
it is completely stationary
show current code
so it currently only goes in 1 direction
` void Update()
{
horizontalInput = Input.GetAxis("Horizontal");
verticalInput = Input.GetAxis("Vertical");
characterController.Move(Vector3.right * speed * horizontalInput * Time.deltaTime);
characterController.Move(Vector3.forward * speed * verticalInput * Time.deltaTime);
transform.eulerAngles = new Vector3(transform.rotation.x, cam.transform.rotation.y, transform.rotation.z);
}`
the movement works just not where im facing
first combine your move into 1 call
so make horizontal and vertical all in 1?
I would use transform.Rotate(Vector3.up * rotVel);
im not sure what im doing right now
Vector3 move = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
controller.Move(move * Time.deltaTime * playerSpeed);
?
characterController.Move((transform.right * speed * horizontalInput * Time.deltaTime) + (transform.forward * speed * verticalInput * Time.deltaTime));```
transform.rotation = Quaternion.Euler(0, cam.localRotation.y, 0);
with this i cant move at all
oh
nvm
this should be cam.transform.localRotation.y probably
sure, its just an example
alright so
my player still doesnt go in the direction im looking
oh wait
weird
the player rotates like extremely slow
when the camera rotates around 360 degrees the player only moves 1 degree
the tag doesn't work spammy dude
nice job deleteting your racist text
thanks
you knew you was gonna catch a ban
<@&502884371011731486>s can see deleted messages 😉
so the camera rotates fine but player doesn't ?
yes
the player rotates from 0-1 when the camera goes 0-360 total
did you reference the correct camera object?
i would think so, otherwise it shouldnt move at all
it couuld be grabbing wrong object rotation
yeah ill try some stuff, should i remove the players rb
cause it has the character controller on it anyway
why do u have a rigidbody
not sure why u added it, anyway does it work without it?
it was there from before, and yeah it moves without it
player rotation still is the same as b4 tho
should the camera it uses not be a child object of the camera holder?
alright
ideally if you were referencing camera holder it wouldn't be an issue prob
i tried that and it didnt even do its small rotation
same thing
should i send the whole code again?
https://hatebin.com/qrzoppudrj (player)
try transform.localRotation = Quaternion.Euler(0, cam.transform.eulerAngles.y, 0);
alright
I did not adhere to my own advice 
can you explain this afterword btw
used the quaternion instead of euler
-1 to 1 vs 0-360 or -180 to 180 , lol i forget
euler uses degrees
its showing you euler angles yes
if you hit inspector debug mode you can see quaternion values iirc
oh thanks
!code 👇
📃 Large Code Blocks
Large code blocks should be posted as 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 get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
working btw thanks
How do I make it so that when I press to sit down, he sits down if I'm even standing still and so that I don't have to hold the squat button?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
if you want to toggle crouching rather than holding it then instead of subscribing to the canceled event for the Crouch action and checking the current state of the button in onCrouch, you'd want to just flip a bool each time the button is pressed
hi all, whenever I close my game I get 1000s of copies of this error and I have no idea where to find out what serialized anything has been "disposed" of
NullReferenceException: SerializedObject of SerializedProperty has been Disposed. UnityEditor.SerializedProperty.get_objectReferenceInstanceIDValue () (at <fe7039efe678478d9c83e73bc6a6566d>:0) UnityEditor.EditorGUIUtility.ObjectContent (UnityEngine.Object obj, System.Type type, UnityEditor.SerializedProperty property, UnityEditor.EditorGUI+ObjectFieldValidator validator) (at <fe7039efe678478d9c83e73bc6a6566d>:0) UnityEditor.UIElements.ObjectField+ObjectFieldDisplay.Update () (at <fe7039efe678478d9c83e73bc6a6566d>:0) UnityEditor.UIElements.ObjectField.UpdateDisplay () (at <fe7039efe678478d9c83e73bc6a6566d>:0) UnityEngine.UIElements.VisualElement+SimpleScheduledItem.PerformTimerUpdate (UnityEngine.UIElements.TimerState state) (at <79c7b132c51745cbae03eebea8111c0e>:0) UnityEngine.UIElements.TimerEventScheduler.UpdateScheduledEvents () (at <79c7b132c51745cbae03eebea8111c0e>:0) UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.UpdateSchedulers () (at <79c7b132c51745cbae03eebea8111c0e>:0) UnityEngine.UIElements.UIEventRegistration.UpdateSchedulers () (at <79c7b132c51745cbae03eebea8111c0e>:0) UnityEditor.RetainedMode.UpdateSchedulers () (at <c91a25f185b743118a39aafa100dff09>:0)
perfromer?
?
try resetting your Layout
what does a Layout mean in this context?
no. i didn't say "subscribe to the performed event instead of the canceled event"
your error seems to be related to something with Unity Editor UI
maybe window or something not disposed properly
could you give me a hint where to look?
where to look for what?
Where to look, I'm just new to this topic
There is nothing to look for. You just.. make a bool
I still don't understand why the squat animation doesn't work for me right away, but only in motion
that seems to have done it for now, thank you!
if I rerun the game and it explodes again I'll come back
lets see
im trying to make a character select screen but i cant the get player to spawn```cs
public class SelectClass1 : MonoBehaviour
{
public int whatClass = 0;
public bool pickedAR = false;
public void ARClass()
{
whatClass = 1;
}
private void Update()
{
if(whatClass == 1)
{
pickedAR = true;
}
}
} cs
public class ChangeClass : MonoBehaviour
{
public SelectClass1 Class;
public GameObject ClassSelected;
// Start is called before the first frame update
void Awake()
{
Class = GetComponent<SelectClass1>();
}
// Update is called once per frame
void Update()
{
if(Class.pickedAR == true)
{
ClassSelected.SetActive(true);
}
}
}```
well for that you need to look at the conditions in the if statements where you set the isCrouched bool on the animator
ok yep it blew up.... I think the problem is that I have data that has been serialized and then I'm dumping it when the game stops. like a list of serialized things. and then when I close it, we dump them out of memory but Unity wants to hold onto that data
here the error
what version of Unity are you on?
could be 2022 bug
?
will that be right?
2022.3.10f1 which I believe is the current LTS?
have you considered testing it?
yes, I also been having weird SerializedReference errors
I've just tested it, nothing has changed
I am going to just un-serialize stuff. I had it serialized so I could sneak some peeks into my data at runtime. but if it that just actually explodes then that's not worth it.
I just restart editor and fixes it sometimes
you could always try deleting library folder and rebuild
maybe some nasty bad cache lurking
are you sure you actually saved the code?
yep, un-serializing my newest thing fixed it.
weird
he himself is saved in the rider
my guess is this is what happens when you throw around "system.serializable" as a "show me this in the inspector" and ignoring the fact that setting something up with serialization has genuine memory ramifications, I dunno
chalking this one up to something I just had to learn the hard way and moving on, thanks so much!
idk I never had issues with Serializable
def try maybe making unity package with the same assets and use something like 2021 as test
can someone help me
this might sound dumb but can anyone help me with this?
what is "this"
which one is the spawn ?
its a code where if the player goes above the certain x, the camera goes to the new vector
change class
help guys
so whats the problem
maybe there is something to choose?
check console for errors / debug your bools
the camera just wont shift to the new vector
and where did you assign that?
where did i assign what? the script?
the camera just wont shift to the new vector
where did you tell it to shift to that vector
vector = new Vector2(307, 126);
@rich adder this it the error
where is the camera being assigned to this vector
so the distanceJoint is totally fine
it spawns at the hit.point
however.. the line renderer set to the same position with the raycast hit does not.
it spawns ontop of the game object.
it looks like this (see image)
as you can see the distance joint connects (by touch, with ray cast) but the line renderer spawns ontop of the game object. the reason why it's far from the object is because its swinging at themoment
you're just storing 2 numbers right now
so it looks like you haven't assigned something
here's the entire thing if it helps
again..where are you assigning this vector to the camera.?
this is just a struct of 2 numbers
it does nothing by itself
its like expecting 123 to do something
this is the inspector but i cant assign anything to the Class
doesn't vector = new Vector2 mean im assigning the camera to have a new vector?
no you're just assigning new numbers to your struct vector
not actually doing anything with them
use those numbers to assign it to the camera if thats what you want
reference the camera's transform
assign it to the position
which gameobject has that script ?
SelectClass1
A game Manager. do i need to switch it to the player?
?
are they both in the scene?
yeah
well that's certainly not a helpful response. and yes, it is important to make sure that you have saved your code and that it has compiled in unity or else any changes you make won't actually be applied
you should also remove Class = GetComponent<SelectClass1>(); since youre gonna assign it in the inspector
it was about the animator
show me inspector for this object
huh?
which one
now I can sit down while standing, now how do I make it sit down when pressed so that I don't pinch the button?
i already told you how to do that
it was literally the first thing i told you
#💻┃code-beginner message
the one that has SelectClass1 script on it
I'm sorry, I don't understand much yet, could you tell me in detail or show me on my code?
go read [this message again](#💻┃code-beginner message). i will not be writing the code for you. if you have questions about how to do something specific related to it, then ask a specific question. do not just respond with ?
ok are you dragging MainMenu object in that slot of ChangeClass
how do i do it if its in a differnt sence
jesus h christ
tbh you can just carry over the values from one scene to another
doubt you need cross references for this one, doing that in update is overkill
store it in an object that persist scenes, find it. Use singleton like it says
public int whatClass = 0;
you should probably getting into doing enums
public enum Classes { Scout, Medic, Assault } //eg
public Classes SelectedClass;
SelectedClass = Classes.Medic```
@rich adder sorry for disturbing but i tried this but still didn't work, any suggestions?
That is offsetting the transform of the object that script is attached to by a huge amount
Is that what you wanted?
i just want the object to go to that new vector
kind of like just teleporting there
Then remove the second transform.position
Just do
transform.positions = new Vector3(values)
ah i see what was my problem, I previously used vector (the variable referring to the vector2 of the object) = new Vector2
Guess that doesn't work
and u have to directly call the position of the object
thanks an
man*
@rich adder I have no idea on how to do it can you help me again
it would've if you did transform.position = vector;
ah i see
wdym , whats the problem?
spawning in the player
i put what you told me in the script and it works but i dont know how to spawn the player
let me see what you have so far.
i only have the code you gave me. i got frustrated and deleted the script.```cs
public class SelectClass1 : MonoBehaviour
{
public enum Classes { Scout, Medic, Assault }
public Classes SelectedClass;
public void ARClass()
{
SelectedClass = Classes.Assault;
}
}```
why did you copy that lol it was an example of enumeration which i said you should learn.
Anyway you can just simplify this to be the class that also spawns the player and persists to the next scene
you will need this
https://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html
dont copy and paste script, read what the function does
its 1 line
its important you learn/read these things as you will be using them often, I dont have time to explain why they're useful just read description
@rich adder i got it but when i switch scene i cant get the camera. and its important to my player
error: MissingReferenceException: The object of type 'Camera' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
I will be back in ten if you answer
which script is showing this error?
Always show your code. We cannot see your screen.
the error is on SelectClass
public class SelectClass1 : MonoBehaviour
{
public enum Classes { Scout, Medic, Assault }
public Classes SelectedClass;
public GameObject Assault;
public void ARClass()
{
SelectedClass = Classes.Assault;
if(SelectedClass == Classes.Assault)
{
Instantiate(Assault);
DontDestroyOnLoad(Assault);
}
}
}
oh, you put DDOL on the wrong object.
I was saying make this class selector also your spawn script in the next scene so put DDOL for it then spawn player when scene is changed
https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager-sceneLoaded.html
Also make sure you spawn a prefab of the class
I'm trying to figure out a solution for when I change scenes. With each scene I need to load things like player position on load, Location of camera limits/clamps, name of the scene, and in each case it's going to generally be different. Is there a prefered way to do this? I have a general idea of how I could do this but it seems messy, where I would create a list or library and just pull from that
would i put the DDOL in the start or like a update
are you asking about saving those values or do something on scene change?
Show the full error stack trace
What is this error?
Assets/Scripts/PageSwitch.cs(4,17): error CS0234: The type or namespace name 'Unity' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
awake/start would be fine
Show a screenshot of your IDE with this script open please
im using rider
Make sure you've saved the script, then clear the console
worked thanks
@rich adder something like this? ```cs
public class ChangeClass : MonoBehaviour
{
private SelectClass1 Select;
private void Start()
{
DontDestroyOnLoad(Select.Assault);
}
}```
I have a system that could handle the saving. It's that every scene has different values and I'm not sure how I should store for each scene and move the data.
Not in the "I'm puttin the data on a JSON file" sense, but that I don't know how I should pull the data on load. Something like 'load scene' then based on the scene loaded the parameters are then loaded from a library.
how could i access data from other script in Unity Job without need to copy that data?
Load to native/unsafe container and use pointer access
Or you are not talking about job system, then just reference the script
https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager-sceneLoaded.html
Check the scene name/index then go from there for specific thing you want load
Negative
what does your next scene setup look like ?(how do you spawn player etc.) @violet topaz
Sorry I got off but I will see tomorrow
something like this? i dunno how pointers work yet
class Chunk{
public NativeArray<BlockType> VoxelMap;
}
class ChunkManager : MonoBehaviour{
public public NativeArray<NativeArray<BlockType>> VoxelMaps;
}
[BurstCompile]
struct ChunkJob : IJob{
public NativeArray<NativeArray<BlockType>> VoxelMaps*;
}
unsafe does
ik i just typed it like that
Public unsafelist<something>* some ptr
Don’t remember to add the native disable unsafe ptr restriction attribute on it, then access it through some ptr->property
-> is operator of dereferencing pointer address
Actually i suggest you just copy the unsafe list into local variables then assign it back at the end of the job, continuously dereferencing address is quite expensive
i need to check neighboring chunks to update them properly, and i wanted to avoid copying voxelMap of all neighboring chunks
Copying an unsafe list only costs 16 byte iirc,
whats "iirc"?
If i remember correctly
Though for some readonly container i just copy the base addr and count to the job, i dont even need its capacity
huh? i think i miss something, how copying 6 x short[64 , 64, 64] is 16 byte 🤔
Copying the pointer is 8 bytes, count and capacity together is another 8 bytes
i think i will start learning C++ to understand these pointers 😂
i never seen someone using them in C#
You pass the pointer only (low level reference) to the job
i saw only 1 guy doing Class that was working somehow like pointer
this is being called from a pointer enter event trigger inside a ui, how can i get the gameobject of the ui that the mouse entered?
public void MouseHover()
{
moveTarget = true;
}
probably by using raycast from mouse pos 
really there is no paramater that describes the gameobject? i recently switched from roblox lua to unity and normally i wouldve done something like this
public void MouseHover(gameobject)
{
if gameobject.Name == "Right" then
end
moveTarget = true;
}
The function is called on the GameObject that was hovered, so you can access it with gameObject or this for the component reference.
I suggest checking out how MonoBehaviour and components in general work in unity.
ahh okay thankyou
will do
I'm making an idle game where the damage is automatic every x amount of time once combat starts
What functionality should I use for this?
Both damage and amount of time are variable
Timer in update or coroutine
Does this look good?
Would it prevent missed damage because of low fps?
{
timeToNextAttack -= Time.deltaTime;
if (timeToNextAttack <= 0)
{
DamageMonster();
float leftOverTime = timeToNextAttack;
timeToNextAttack = attackSpeed - leftOverTime;
}
}```
Timetonext attack+=attackspeed
Or you can check how many period is passed between frame and deal number of period*damage
ah yeah that makes more sense
would still break when fps is lower than attackspeed though 😦
Then you need to check number of period passed
Hey, I've been trying to modify the material of a game Object through script.
But due to the face materials of my object being rendered by probuilder, I'm having a hard time changing it
Changing the main body material is working fine, but the face material change, I don't know what to write exactly to affect it(since it's created by probuilder, I don't know any of the probuilder codes)
the error says enemymanager.cs
there is same error in your enemymanager.cs, then correct this script
this js came up next
Guys
I need help with ADS
I don't know how to add aiming down sights to my weapons
Do I need some sort of animation?
if i may ask what is that?
class A{
public A(){
}
}
public A(){} is constructor of class A
show you script first , i may misunderstand the error
{
public GameObject Wolf;
// Start is called before the first frame update
void Start()
{
int levelCurrent = PlayerPrefs.GetInt("levelCurrent");
if (levelCurrent == 1)
{
Instantiate(Wolf, new Vector3(transform.position.x, transform.position.y, 0), transform.rotation);
Instantiate(Wolf, new Vector3(transform.position.x - 15, transform.position.y, 0), transform.rotation);
Instantiate(Wolf, new Vector3(transform.position.x, transform.position.y - 15, 0), transform.rotation);
}
}
// Update is called once per frame
void Update()
{
}
}```
i dont see anything wrong in this code...
have you tried to restart the unity?
did you save the script and is this the exact script you're using without anything cut out?
it also does seem like these errors happened way apart from each other
entire script
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class EnemyManager : MonoBehaviour
{
public GameObject Wolf;
// Start is called before the first frame update
void Start()
{
int levelCurrent = PlayerPrefs.GetInt("levelCurrent");
if (levelCurrent == 1)
{
Instantiate(Wolf, new Vector3(transform.position.x, transform.position.y, 0), transform.rotation);
Instantiate(Wolf, new Vector3(transform.position.x - 15, transform.position.y, 0), transform.rotation);
Instantiate(Wolf, new Vector3(transform.position.x, transform.position.y - 15, 0), transform.rotation);
}
}
// Update is called once per frame
void Update()
{
}
}```
i put the int levelCurrent = blah out of the void start() to see if itd work (dumb ik but im new so js trying)
no ill try that next
lol. alright.
sometimes that happened 🙂
and some tips, write 'wolf' in lowercase. if you using 'W', you'll messed up with function in the future. hope this help 🙂
Nevermind I figured it out
So much easier than I expected
i changed it to WolfEntity cause it was alr doing sum like that
should hopefully work
Guh
Any good tutorials to follow for a beginner 2D floating game? I unfortunately am just a newbie so everything is overcomplicated and i have like a week to finish a school project 
YouTube or !learn
🧑🏫 Unity Learn can offer you over 750 hours of free live and on-demand learning content for all levels of experience! Make sure to check it out at https://learn.unity.com/
Anything will do if you only want to finish it
a week for finishing one game is a bit short....
Depends what kind of game
A very beginner-ish float game
A simple one could be done easily in one day
What is a float game
Imagine making flappy bird within a week with no graphics or animations and just make 3 different levels of it
Tho it shouldn't move like flappy bird
It should use gravity to move and float around the screen
If you don't press any buttons it just falls to the bottom of the screen
Yeah, like flying part in geomtry dash
and change the movement
Yeahhhhhhhhhhhhhhhhh a bit of then problem is the fact that I can't program that well, this assignment is a pain cuz i kinda have to force my way with it instead of taking my time learning it
Yeah, so follow a flappy bird tutorial
If you want a hand-made map then make a background scroller
And look up how to make a smooth fly movement
Yeah I will basically need geomtry dash type of game but only the flying part
I assume you did play geomtry dash ._.
Ahhh
But I know what you mean
Good luck
Where is the Loop Time box to make the animation play infinitely?
you can check in animation file and tick "loop time"
#💻┃unity-talk , this is code related question
is there a way for gpu profiling when testing on mobile?
So, I want to play a AudioSource on disable. Which obviously creates Can not play a disabled audio source error.
What would be a good solution to this? I could generate a prefab/new game object and play it there, but, I feel like there must be a better solution?
I would have figured PlayClipAtPoint is what I want, but. Turns out I can't set the spatial blend/curve on it... So there goes that option.
I'm trying to add a force on a rigidbody perpendicular to current velocity. It doesn't matter what direction it's just to test something
Why isn't this working?
Does it even call this piece of code, and can you debug.log the velocity you are adding?
Try Vector3 perpendicularVelocity = new Vector3(-rb.velocity.x, rb.velocity.y, rb.velocity.z)
Then addforce to that variable?
I think my approach is completely wrong
i'll try that
@quasi birch it's doing the same thing, just speeding me up
You don't AddForce to a variable though? You AddForce to a rigidbody that has a velocity.
if my current velocity is north, my new one should be east, or west
The vector you create is either 0 or something weird.
Oh, you say its speeding you up 
Just try adding force, transform.right?
shouldn't be transform though should be the right of my velocity
would it work if i did
Transform.right is just a vector pointing right of the transform of length 1, sure you can use that.
but doesnt that depend on the rotation of my player
anyone?
Well then I don't understand what you are even trying to do. If you want to slow down your rigidbody you can just add Drag onto it, or create an inverse vector and addforce that vector.
Guys I've been having a slight problem with my character movement, it does not adpat to the camera position, so when im pressing W it will go foward and S backwards etc... but if i rotate the camera and look back W will still make me go forward instead of adapting and going back, if anyone could help me I would be thankful, here's the code I used (This is the player movement code).
using System.Collections.Generic;
using UnityEngine;
public class playerMovement : MonoBehaviour
{
Rigidbody rb;
[SerializeField] float movementSpeed = 6f;
[SerializeField] float jumpForce = 5f;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
rb.velocity = new Vector3(horizontalInput * movementSpeed, rb.velocity.y, verticalInput * movementSpeed);
if (Input.GetButtonDown("Jump"))
{
rb.velocity = new Vector3 (rb.velocity.x , jumpForce, rb.velocity.z);
}
```
Your movement doesn't use the camera direction at all . . .
It doesn't know which way its facing or rotation in relation to the player . . .
Alright thank you, I will try to find a fix for that, just letting you know I have no code experience with Unity or C# ever before I’m trying my hardest here
You could’ve rephrase that in a more friendly way, the way you’re putting it kinda discourages a beginner to keep going with the … making it seem it was not normal for a beginner to make such mistakes
can someone help me understand how Mathf.Clamp() works
specifically the minvalue and maxvalue parts
If the number you pass to it is smaller than minvalue, it returns minvalue. If it's bigger than maxvalue, it returns maxvalue. Otherwise it returns the original number.
that part is understood, does it use Vector3.zero or Quaternion.identity when putting like (value, -amount, amount)
It has nothing to do with vectors or quaternions
ok
It's a method that takes in 3 parameters
ok
ok so, if i want to clamp my Y value of an object from where its currently is would it be like
i_suck_at_naming_variables = Mathf.Clamp(object.transform.position.y, object.transform.position.y-minvalue, object.transform.position.y+maxvalue)``` ?
hello guys! i have a 3d spider walking on the terrain. But somehow it goes throught spheres, idk why
yeah i think
No
then how would i do that
Don't subtract the values from the current position. Just pass in the limits you want
wdym by passing the limits i want
min and max
wait actually
just put them as they are
i made a mistake nvm
clamp an object's position or/rotation to a certain value (in this case -30, 30) while considering its Y value
Then your limits are -30 and 30, just pass those values
i still dont understand the second part xD
That's what you wanted?
no
so
i want to take an object's rotation value at one specific time(lets just use like 0, 110, 0 for an example) and then clamp it for -30 degrees and 30 degrees on its Y axis while considering its current rotation so itll be clamped between
x, 80/140, x
with x being an unclamped value
you know what is "clamp" right ?
does it have another meaning besides Mathf.Clamp()?
Well then you save the values at the specific time you want and use them as min and max later
clamp means "if im under minvalue, i become equal to minvalue, if im above max, i become equal to max. And if im in between min and max, i stay as i am"
yeah or you wanna use them later ?
ok
why raycast is going through, help :'(((
Huh? I just said your code doesn't use the camera since you said it does not adapt to the camera. It has no idea about the camera or what it is since the camera is not in your code. How is that rude or discouraging? I'm telling you what you're missing . . .
The value you want to clamp will take the lower value if initially lower than the minimum, remain the same if initially within the range, or take the higher value if initially higher than the maximum. That's how clamping works . . .
Hey, I've been trying to move my instantiated object to hand, I was trying to get script component attached to the instantiated object and fire the method from here but for some reason, it just doesn't work.
You can't trigger a method from a different script or it has something to do with it being an instantiated object?
I can move it raw by changing the transform.position of the object but I can't get the component and use methods from the component I got(although the editor shows that I did get access to the component during runtime)
post the MoveToHand method code
ok, so that is not actually doing anything
what did I do wrong?
you say to want it to move but there is no movement code in there
the desired position creates the movement
how?
but how does desiredPosition affect transform.position?
every 10 or so times i stop the application i get this screen infinitely
have to force-stop unity and it sometimes causes me to lose progress, i've tried searching up the issue but no dice
this code is in GenUnit?
yeah.
should be fine unless something else is modifying desiredPosition
What calls MoveToHand
oh yeah, the start function in GenUnit says gameobject.transform.position = desiredPosition
But shouldn't the new functions overwrite the old, my card movement on other script is comepletely fine
which will run after MoveToHand is called
I feel like we're missing a lot of key information here. Might be good to post the full scripts instead of single functions
i just launched my project and have all these errors. how fucked am i? 🙂
Not very.
I've seen this issue several times. For some reason, one of your packages just...refuses to see another one (or itself, in this case)
You can probably just remove the Test Framework package, from the package manager window
it is a dependency from a bunch of crucial packages so i can't remove it sadly
Have you done a "Reimport All" yet?
alternatively, just deleting the Library folder entirely
that's what I reach for first when this kind of thing happens
i haven't, never had this issue before. where would i go to reimport all?
Hello,
I've a RTS project on Unity and wanna talk about settings and programming configurations.
I Kinda know how to program but need to be sure how to set script and organizing stuffs,
which problems to avoid etc.
reimporting all still gives m the same errors :/
what do you mean by configuration? as for script organization, you can follow or setup a style guide for yourself: https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/identifier-names
https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions
Okay, time to ask you guys about basic math(I successfully solved the previous problem.)
How do you increase a value by 1 everytime this method gets run?
I can't believe it is so hard to write such a simple concept
Originally it was CardsinHand += 1 but that only gets read once and sets it to 1 and doesn't go higher
make sure it gets call everytime you want
try debug.log it to see it get call at the right time
yeah, I am doing that.
I don't know how to do the math part
I'm pretty sure the math is wrong otherwise it should just increase
cardsinhand+=1; shoud do fine not sure whats wrong with that
thanks for the reply RandomDiscordInvader(), for configuration I mean how can I manage all the game's scripts in order to have an efficient flow? databases, in game function, editor etc.
how can I handle all the different scripts?it's bettere only few script compacted or multiple, one per category( such as unity data, buildings data, unity behavior, etc?)
thanks for the response.
you can also do this instead:
if (!IsinHand)
{
...
}
just a personal preference though, but it does lower the amount of code you are writing
CardsInHand += 1 should work. It’s also equivalent to CardsInHand++. If the CardsInHand doesn’t keep going up, then that means either: 1) the ++ isn’t actually getting called, or 2) something else is setting it back down
That will add 1 to CardsInHand. If that's what you want to do, that's how you do it
the whole PreviousInHand is unnecessary imo
Or 3) You're incrementing a different CardsInHand every time
oh, that depends on how to design or build the game. there is n one solution for number of scripts. it solely depends on what you add to your game, like how you build/architect your units, and what type of systems you create
if you haven't built anything yet, i suggest looking at tutorials since an RTS is a huge undertaking. programming is iterative; your first solution will not be your last or final implementation of that specific feature . . .
i would select cardsinhand and ctrl+R/cmd+R to find all the references to it
to see if something else is changing it
specifically, on the setter
i also think giving CardsInHand a setter is unnecessary
I assume this script is in a card’s class or something?
there should be a hand which has something like a List<Card> hand; and then you just do hand.Add(this card);
and if you want the hand size, use hand.Count
It is not hard. += 1 is correct.
I got it
It's because I put CardsinHand inside my General Unit script.
Every Unit has it's own Cards in Hand and that's why it wasn't increasing
thx for the tips guys
so it was increasing, you just were looking at Y after increasing X and wondering why Y hadn't increased
what I’m getting at is; each unit probably needs to know which cards it has in its hand
so you need a list of cards tied to each unit, and you can call .Count on that list to know how many cards are in that unit’s hand
Why is this error showing up even if everything looks correct?
Of all those screenshots, you failed to show your trigger
Parameters appear in the "Parameters" list.
These four rectangles are animator states. You can directly enter an animator state with Animator.Play, if you'd like.
Animator.SetTrigger is used to set a trigger parameter.
Parameters are used to control transitions and blend trees.
Parameter list is empty
you don't need to 'access the animator state' here. If you just want to switch to a specific state on command, use Play("theStateName")
So then that'd be why it says the parameter you're looking for doesn't exist
Because it doesn't
what the normal fov for a camera
Directly playing states is perfectly reasonable, although it does mean you're doing everything manually.
I mixed up between animation state and parameters, my apologies
I consider 90 to be a pretty safe default. Note that this is a horizontal FOV, and Unity uses a vertical FOV by default.
thanks
unity's default appears to be a vertical FOV of 60, which is around...90 horizontal, at least in my setup
I am not familiar with why you'd use vertical over horizontal.
explain your problem, then
why is it like this
How is it any more manual than playing it using a trigger?
this is not a code problem. you should ask this in #💻┃unity-talk
mb
A trigger parameter does not directly set the state.
like what
I'm sorry I just don't understand animation much
Transitions can look at parameters to decide if they can be taken.
For example, you can have four animator states in a row. The first state can have a transition to the second state that depends on a trigger.
The other two transitions can be unconditional.
Setting the trigger would play states 2, 3, and 4 in sequence.
So, for example, you might set a trigger to make the weapon reload animation play
When it finishes, you can automatically transition back to the idle animation.
That way, you don't have to manually play both the reload and the idle state.
Having bit of an issue setting up Analytics for Unity:
My code contains:
using UnityEngine.Analytics;
And I tried to call even like so:
AnalyticsResult result = Analytics.CustomEvent("Skin Purchased" + skinToPurchase.name + " : " +skinToPurchase.characterId);
Debug.Log("Analytic result: " + result);
Yet I get this response:
Is there some setup thats incorrect ? 
why isn't the animation playing consistently?
I implemented that
Sometimes the animation plays, sometimes it doesn't
This is the reload coroutine
when u inspect animator widget what happens when bug occurs ?
theres usually some other state that blocks it from working properly or gets straight away overriden by a different state
How do i do that
Press play in Unity Editor. Select the object that has animations while in play. Open this up:
ideally have animator on 1 screen and game on another
and play it but keep an eye on what happens
in animator
that will let u troubleshoot if the transitions flow as u expect them to and what is currently being executed
Ah I see
Absolutely brilliant
It seems that the problem is that the animation stays at the end of its playing time
I'll screen record this
why wont .FindGameObjectWithTag come up?
Here
your compiler isnt picking up unity ? 😄
do other auto completes that are unity specific work ?
I am not rly animation expert, but for starters have animation exit
It is a static method too so not sure if it should show up there
GameObject not gameObject
Unity is crashing when I try to call a scene
I'm pulling data from a JSON file based on the previous save.
Any help appreciated
What does "call a scene" mean?
It does seem like the reloading is working since when the animation doesn't play you can't spam
It's just that the animation is stuck at the end of its play
unless another animation takes over
*Load a scene
Trying to use LoadSceneMode.Single
In the crashing version, the loadscenemode.sing isn't commented out
because you dont have exit applied
How do I do that? I'm sorry I'm really new to 3D animation
either attach it to this
or to some empty state
depends what you aim to do exactly
What do the crash logs say?
ye that will return u back to idle once those animations stop playing
alternatively u can point them to "exit"
as once exit concludes
it goes back to "entry"
either way should work fine I think
empty state with no return is usually for stuff like death animation
because u dont want nothing else to happen once it triggers(well that depends on a game I guess)
I'm not getting one. It's more of a soft lock where the whole system freezes when I hit play; nothing is responsive, so no error messages.
Sounds like you have an infinite loop in your code
In some script in the new scene
Thanks mate
Works perfectly
no problem
Thank you, I'll take a look
write a for loop
it's a super short loop
But let me ask you a different question. Why are you using a class instead of a struct here?
it's 32768 itterations
indeed
^
idk
classes are cool
if you use a struct you don't need to do anything other than the second screenshot
is there a reason not to?
A class will use a bit more memory here too
and need to be garbage collected later
Guys
How do I make my pistol game object play its animation for sprinting when the only sprinting check is done on the PlayerMovement script?
Which is obviously attached to the player, not the pistol
converted to struct, got this error
i keep getting this when trying to add my script to an object in the game, I have modified and saved the script and the class name does match the file name, is there something i'm missing?
Make sure that there are no compile errors and that the file name and class name match
Is the class name of the script the same as the script name?
Is Button even allowed? Wouldn't that give a conflict with Unity's Button 
Do you have any compile errors
These need to match
Show a screenshot of your console
^
i dont think so? it'd show as an ide error if that were the case
Show us the Unity console instead
oh the errors were hidden for some reason, this is the error: "Assets\Scripts\Selection_Settings.cs(18,29): error CS1061: 'Button' does not contain a definition for 'interactable' and no accessible extension method 'interactable' accepting a first argument of type 'Button' could be found (are you missing a using directive or an assembly reference?)"
That would be because your Button class has nothing named interactable on it
why do i need that? i just want a simple script to be a button, all it does rn is just print to the console
You named your own class Button, so it's picking up that one instead of Unity's Button
oh, well that's annoying
Well, Selection_Settings is attempting to use a property interactable. Since you've made your own Button class if you want it to work with that you need to implement all the stuff Button normally does
my b lol
yo guys does anyone how can i make my itens stack when i pick em up to the inventory?
make a List
or Stack/Queue
i mean they do stack but i still figuring out a way for them to stack when entering the inventory
when i pick them up
you'll have to check if the inventory contains a compatible object
Loop through all the slots, if the item in the slot is the same as the one that is about to be added, add it
you may have to do this repeatedly if you pick up a big stack
^ + discard items if inventory is full
Note that this is going to have nothing to do with the hierarchy. There's no magic button to make the icons "stack" together or something.
For each item stack in the inventory
If the item is compatible, and the slot is not full
Add the most possible items to the slot
End
Loop
Drop the remaining items if any, the inventory couldn't hold more
That's how the loop should look like
How do I make an object move along the Edge Collider 2D without slowing down?
rigidBody2D.velocity = new Vector2(1f, 0f);
This will make it float to the right
I have the player object + collider with a slippery material(0 drag)
Player object has 1 gravity scale and 0 drag.
raycast down maybe and rotate your forward based on normal?
haven't done too much 2D so take it with grain of salt
hey friends. i've got a melee character controller that has its recoil settings influenced by a child "combat entity". character controller is responsible for movement & stats etc, whilst the combat entity handles attack functions. https://hastebin.com/share/ovarozebuz.csharp heres the player script. https://hastebin.com/share/ucuhenawub.csharp heres the combat entity. i've got 2 issues atm. if my character attacks down, it recoils up regardless if it actually hit an enemy. i'm struggling to understand how i can get the combat entity script to properly tell the player controller script if it should be recoiling on the x or y axis when an enemy is hit. the other issue is that if the player hits an enemy to its left or right, i'd expect a respective recoil in the opposite direction on the player, but it doesnt do anything, actually, regardless of the force I apply
I need a simpler 2d solution 😄
is there something like "forward" in 2d?
right/up
depending which way sprite faces / orientation of your game (topdown vs sideview)
yeah I want the sprite to always be touching the edge with the bottom/legs
doesn't brackys have something like this with that line rider game?
maybe its the same process
📃 Large Code Blocks
Large code blocks should be posted as 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 get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
Following a tutorial for the new input system, this zoom control is acting weird. Each click of the mousewheel sends it to max or min, continuous scrolling makes it kinda jitter in place. Sometimes one direction will stop working entirely until you scroll the other direction first... Tutorial said to normalize the vector 2 in processors to stop it jumping to max/min, but that didn't help.
{
if (context.phase != InputActionPhase.Performed)
{
return;
}
// Adjust the current zoom value based on the direction of the scroll - this is clamped to our zoom min/max.
CurrentZoom = Mathf.Clamp(_currentZoomAmount - context.ReadValue<Vector2>().y, ZoomMax, ZoomMin);
}```
And in late update:
``` _actualCamera.transform.localPosition = Vector3.Lerp(_actualCamera.transform.localPosition,
_cameraPositionTarget, Time.deltaTime * _internalZoomSpeed);```
📃 Large Code Blocks
Large code blocks should be posted as 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 get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
why no work
We need at least the error message.
Hi. One question, is there something like transform.TransformPoint but without taking into account the transform Z rotation please? like as if it was in a 2D plane kinda
you dont have a variable rb decalred or it is the wrong type
you either dont have rb defined in the script or its different type from platformRb
'
You cannot put a Rigidbody into a Rigidbody2D
As you're in a 2D project, .platformRb should probably be a Rigidbody2D.
Same for rb
The types must match, here they don't. You're trying to put a square into a round hole
how can i grab the child of an object? google says to use the getchild method but i'm not seeing that as an option
This method only exists on Transform, so if you have a GameObject variable, you need to do variable.transform.GetChild(n)
ohhh
does the object returned equal the whole child object or just the child's transform?
i kinda just answered my own question when trying to use it, how can i get the whole child
The transform, but you can get the object with .gameObject
not just the transform
Intellisense will tell you that as you type the method name
and now how do i grab the TMP text component off that with getcomponent? i just dont know the type i am supposed to use
TMP_Text
TMP_Text covers both TextMeshPro and TextMeshProUGUI. It's the ideal choice.
You don't really care whether or not this is UI text, and it's easier to type, too.
Let your code editor fix it for you, click the light bulb icon
It will give you suggestions
oh wth, i have never seen a structure like that before, the type is TMPro.TMP_Text
TMP is actually the weirdest thing
That, or using TMPro; at the top
you've never seen a structure like that?
its literally what classes and namespaces are
Which should be the first suggestion in the list
like "System.Serializable"
never seen a type structure like that before, this is because i was missing the proper include, i know how classes work
the actual thing is "Serializable" and "System" is the namespace
Using a directive
using TMPro;
// ...
private TMP_Text _text;
Fully qualifying the name
private TMPro.TMP_Text _text;
Both are valid, but the first one is better to use in the case you need to use stuff from TMPro multiple times
yeah, just never knew you could literally do the whole TMPro.TMP_Text thing
what's the reasoning for the underscore in front of ur variable? i've seen it a lot in more professional examples of coding but never really understood it
same with like m_
It's a convention so you don't mix them up with local variable you declare inside methods
The m_ is a residue from C++ and isn't official for C#, but Unity still uses it
oh so does the underscore denote that it's a class viarable
Correct
gotcha, the more ya know
like s_ is for static
i would like to duplicate this object onto others now but when i do so it does not move the rect transform at all meaning they all display at the same location as the first and not respective to their parent object, is there a simple way to do this in the script?
i figured it out, improper pasting on my end
would (int) Mathf.Floor(Random.Range(0, 9)); be the best way to get a random int from 0 to 9 inclusively with even odds for all values?
or would implicit int casting already cover the floor bit
Int random is max exclusive
oh okay
And casting to int will truncate decimals, it just ignores them. This is slightly different from a floor in that positive numbers are floored, negative numbers are ceiling'd
so i should revise this to just Random.Range(0, 10); if i am setting an int equal to this?
(there's also Mathf.FloorToInt which removes the need to cast to int at the end)
interesting
across 3 boxes, each with 5 separate numbers I want to only have one similar number between the 3, the others are all random. The first pic is an example of how it is breaking right now, both 6 and 1 are present in all 3 boxes when the "correct number" is supposed to just be 6. The second pic is an example of what I mean with the number similar between them being 1. is there a simple way to do this that I am overlooking that is not looping over all the number to see what can/can not be put there?
if you are their can you help me again?
Well, if you're just randomly filling the other numbers, this is something that can be randomly rolled. What you might consider doing is have a list of two of each number that isn't your "target" number, shuffle the list, and pick the first 12 elements from that to make the other numbers
that way you can never have three of a kind, and it's not always the third box that's "missing" a number
And to answer you question i spawn the player in the character select scene and the i use DDOL and move it to the game scene.
Hi I need to make the SDK read-only:
You can start by not posting in every channel, thanks
which is more than one, which is cross-posting.
3 actually, which I have seen
Still one too many