#💻┃code-beginner
1 messages · Page 241 of 1
The copy is made when you load the scene
If you want a singleton you need code to enforce that it stays single, like this #💻┃code-beginner message
So I should make this data load when I press load button in menu
yeah you should not be directly writing things straight to your player controller and cam controller here
just store the GameState on this script in a variable and stop
let those other scripts read the game state from this script when they start up
Im a beginner I just find youtube tutorial so thats why I have it like that, I find it easier to make other things to save if I have it like this but I do understand what you mean by that
For example in the camera script you can do this:
void Start() {
GameState gameState = SaveServiceSystem.instance.data;
this.minPos = gameState.camMinPos;
this.maxPos = gameState.camMaxPos;
}```
okay I will try that
so that means I wouldnt even need to have all that in loadFromJson function, only string json etc and GameState data = JsonUtility etc
why is error here at data, i doesnt say why i have to restart my VS
I assume you didn't make that field yet
i did this
you definitely don't want that first line
sorry I made a typo in my example above
I mixed up two identifiers gameState and data
but still you do need to make the data field on SaveServiceSystem to store the loaded data.
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
this is my full code for saveservicesystem
its to big so that i dont need to send screenshot
sure and like I'm saying you need to add the field
yes i dont really understand how to add that field
Do you understand the difference between local variables and fields?
what data in instance.data represent
it represents the game data you loaded
but you need to actually make the field
you probably want to go through some basic C# stuff
like [SerializeField] data
it doesn't need to be serialized
but no
it also needs a type
fields need a type and a name
the forum is more like something to find and learn specific
looks better
ok so now i do it for death count and player pos
i did it @wintry quarry for everything
but i put all of that in start but what if my data is null then it like if i start new game, then it will just be default settings like death count will be back to 0 or? Will it affect anything because that is in start method
you could either:
- Have the Save System create a default data object
- Have the other code say
if (data == null) // do some default thing instead
ok what now after i did that
I've heard two times that it's good practice to separate your visuals from your code, so you'd make two different gameobjects and make an empty one the parent then add rigidbody, collider and scripts to it. Would breaking this to put a GunTurret.cs script on a tank's barrel be a bad thing? The way I'm planning to do this is by making it so each barrel has different stats and every few levels you can choose a better barrel.
its good to seperate visuals and scripts/logic yes
You could also just make a script that manages all the barrels, or just use SO
Actually yeah, this is about time I learned how to use Scriptable Objects
Well, after I write the actual barrel and tank functionality
You mean having 1 Parent and 1 Child and adding one of them the programming and one of them the visuals? Did I understand that correct?
yeah I think SOs is good for mods and other modular parts
That's what I meant with everything before asking if I should break this, yes
I have a trigger to check if objects are within range of a planet, but since the planet is tagged with terrain, the ground check goes off immediately upon touching the trigger. is there a way to turn this off?
Prefer physics queries such as Physics.CheckSphere() to detect if objects are nearby, instead of a collider. It's probably less expensive than a collider too!
well I need to add to a list on enter and remove from a list on exit...
I guess I don't need to but
Then use Physics.OverlapSphere() instead which returns an array of colliders you can iterate on
if using it often would use the non alloc version
but yeah best tool for i just want all colliders within a area
though how will I know if an object left the range
what do you mean by left range
do I keep track of a list and decouple any that don't appear in the list the frame after?
Ey can I like... do a loop over a specific folder to get references to all objects there and store them a List or do I have to do it manually one by one?
I was using ontriggerenter and exit, idk where to put the exit code now
oh if you care more about if things enter or leave the range would just use a collider
if you just want everything in range at the current moment would use the OverlapSphere
collider had an issue,
but that aside which would be more expensive.
a trigger or an overlapSphere every frame
i would worry about what is the best soultion before worrying about performance
though if using it everyh update use the non alloc version
https://docs.unity3d.com/ScriptReference/Physics.OverlapSphereNonAlloc.html
then overlapSphere cuz it doesn't have the issue I have rn xD
With a physics query you do not need a collider. The code initiates the query and receives the result
pre allocate a array outside of your function with the max amount of items it might carry
that way you can use the NonAlloc version and not incure garbage per frame
And pass a layer mask, so you don't get unwanted objects
I would prefer not to specify a max if possible
it wouldn't be an issue now but it might be later
the NonAlloc version costs way less to call, which is why it was recommended
huge differences when you profile, you'd be surpised..
hmm maybe I'll just assign a higher max for objects that need it then
also just set a max that is like dobule what you expect
nonalloc automatically makes a new array if your current one was too little
iirc
i would have to test but am sure it does not
and that it is not possible with the way its passed in
since its not a out parm but a reference and arrays do not resize
And make sure to only loop with a for loop, and up to the number OverlapSphereNonAlloc() returns. Else you'll get null values, or values from older queries
its not? dam could've sworne.. im prob just remembering wrong
for loop over foreach?
i feel if it did reallocate it would use a list not a array as well
yes
yeah you're right doc says
The length of the buffer is returned when the buffer is full.
Yes because you do not want to go through the whole array, as it may have filled less elements than the actual capacity
yea sry must've misremembered 😅
ah right
the reason why this costs less to use, is instead of allocating memory on call you give it a array to reuse
but it might not fill it every time
ok I'll use overlapSphereNonAlloc 
the array should be a field not a local variable as well
Itd be funny if the nonalloc method alloc'd. But yea that's the one downside if you have a case where you get more results then expected. You'll miss some things
learning more every day 
with how the args are passed it actually would be impossible for it to reallocate the array
haha yeah duhh generetaing new array each time = defeats the whole purpose of non-aloc.
i shall run to my caffeine now lol
the overlapsphere, in update or fixed update?
update
If you re-create a brand new array each frame, just to pass it to the method, then it's basically useless. You allocate as much memory as the regular OverlapSphere.
Whereas with a private Collider[] _bodies = new Collider[50];, it will never be re-created and will always fill the same one
ah right
sometimes I run it inside a Coroutine while loop with yield return 0.2ish
if I need checks without too much frequency/accuracy
i do that for updating targets and wanted positions for NPCS, it does not do it per frame but prolly takes a full second to update the all groups of nodes o nthe map
Yeah there's a lot of ways to optimize it. One would be to reduce the query frequency if you're far from everything, and increase it if there's objects that are close
splits the work over many frames
if you disable the object with the script on it. does that coroutine also stop or does it continue?
coroutine pauses
yup
coroutines require a active object to run
ah ok
its the same reason why need a instance of a scene object to use StartCoroutine as well
Does it pause or does it stop? I'm pretty sure it stops entirely right, you can't resume from where it was
Actually yeah, reminds me
ah so that's why you can't start a coroutine from a scriptable object
Any way to make a 'cooldown' for a method?
Without writing a function specifically for it
I don't want to write the same function 3 times
yes you can pass a Func
if i didnt misunderstand that ur asking
Cooldown for each one, the scripts are entirely separate (so for example, cooldown for firing a gun and another for damage immunity so my player won't get annihilated after stepping on the funny red block)
So make another function with a cooldown?
so could have a cooldown function that accepts a delegate
I meant you can make the coroutine generic enough and pass it a custom time/function to run after done
so 1 function that takes your other function as a argument
Any way without coroutine?
for timer? yeah you can use Update loop but then less neat
Write your own timer
And make it static so everything else uses it? What if I have two different functions?
An even bigger mess
It just seems awfully inefficient
its common to need to write your own stuff to handle a exact case
Why cant I use instance of my SaveServiceSystem code like this
but its very easy to abstract said things and reuse them
I know, but I just thought such a basic feature would be built as a method already
you already got a instance
why get it again
Maybe tell people what the actual error is
Id do it like this
IEnumerator CustomTimer(float time, Action method)
{
yield return new WaitForSeconds(time);
method?.Invoke();
}```
like looks like you are trying to access it like a singleton when you already got the component from GetComponent anyways
What's the error say
If instance is static (it is if you make a singleton), then SaveServiceSystem.instance. That's the entire purpose of making it static.
could still be done with the delegate but thought they wanted a cooldown, so jsut early out of the function too close to the previous call
ah ye true 😅
persnally i would just keep it simple and use a simple timer counting delta time over frames
and return early on the function
if i had a lot maybe abstract it a little
Okay awesome, just ran into another issue
I removed Instance and just called function and it doesnt show error but it doesnt load data. It should when I click load game in menu load scene where the game is and find gameobject with all data stored and load all data, basically like save and load system but it doesnt load my data.
I want it to load this
If I added health for a damage cooldown script I'd have to add an Update() function to actually decrease the timer
because you're assinging it to your local variable data not the field data
you shouldn't be doing this, just use SaveServiceSystem.instance, always
you don't need drag and drop or anything
And uhh, considering I'm gonna have 1k or so objects in the game that have health, this isn't going to be light
Any solutions?
it will be fine
stop worrying about it
if you need cooldown on 1k objects you need to track 1k timers
there is no avoiding that
Too early in development to be thinking about that stuff
just make your game work first
then if I use instance it will show this error
SaveServiceSystem.instance.LoadFromJson(); delete the rest
like a ns or 2 at most
Why did you switch back to the old version? You created a singleton, use it
Can't I just make all of them run in a separate Update() function on a TickRateManager.cs script?
I'm not worrying too much about performance but I'm adding precautions for the future
because i didnt understand it very well and I complicated things for me i find this easier if it will work
it won't work, so no it's not going to be easier
Well not adding, I'm not implementing this right now
you can do it how ever you want, but why combine them all into 1 place when they are all disnective timers for different things
you are just overthinking things mate
get the logic working and easy to read first
Copy paste this 🤷♂️
#💻┃code-beginner message
It doesn't get easier than that
Why are you trying to get an instance from an instance
just use the instance you already have
yes it doesnt but why, I made it first load a scene and then I made SaveServiceSystem ddol singleton so I want it when I click load game to load my game scene and then from that ddol save system script to load that json method
all you do is what I wrote
I showed you what to do
you keep trying to do something else
because u went somewhere and idk how to do it alone so i backtracked
Why? Because it is a static variable
Are you using version control?
what is version control?
so can I just make it
Git with github
Or Unity Version Control
Just copy paste this...
#💻┃code-beginner message
That is a separate issue
You have fixed the error, so that is step one
Is the script from coroutine a DDOL?
yes
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
this is that code
Is the function being called?
No I mean is loadFromJson being called after the loadscene? Did you debug it?
wait let me try
I'm still thinking the coroutine object is not a DDOL, but let's see
Can you show the full !code of this script?
📃 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.
my dash isnt workingpublic void OnDash()
{
Vector2 dashing = Vector2.right * dashSpeed;
Debug.Log(dashing);
rb.AddForce(dashing);
}
I get 20, 0 in the console from the debug but when I press the dash button, it doesnt move. Ive tried rb.velocity as well, weirdly enough, it works if I do Vector2.up (like the jump), but not left or right
Are you setting rb.velocity to a fixed value somewhere else in code
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
its not being called 😦
Like I said, the coroutine object is not ddol
Okay, and is MenuManager on an object that's being made a DDOL in a different script?
If this is a normal scene object it's going to get destroyed when you leave the scene and the coroutine will never finish
no
it'll be gone by then
oh i only made ddol saveservice script
so I make menu manager also ddol?
Load scene is being called , and because of that menu manager is being deleted before it can call loadData
move = inputMap["Move"].ReadValue<Vector2>(); //value of movement per the binding I set
Debug.Log(move.x);
//the velocity.x of the player is equal to the value input-ed by the analog stick/A-D keys,
//velocity.x is changed depending on isCrouch status
//the velocity.y retains, will be modified only when OnJump is called
if (isCrouching)
{
rb.velocity = new Vector2(move.x * crouchSpeed, rb.velocity.y);
}
else rb.velocity = new Vector2(move.x * walkSpeed, rb.velocity.y);
yea in fixedUpdate, thats why I changed it to addforce but i still see nothing being changed. even if its one frame thats being overridden, I dont understand why the addforce wouldnt apply
Or put it on the same GameObject, although you'll have to reset CheckMenu when the scene changes
!code
You're overwriting your velocity every frame, meaning any horizontal force you've added just becomes move.x * speed
📃 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.
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
is this good
Jesus just send it via link man
sry :(, i thought it was short enough
That'll work but unless CheckMenu is also a DDOL you're gonna lose the reference to it as this object transitions between scenes
I need checkmenu only in main menu, checkMenu is gameobject ui that will when I click new game show another UI with "are you sure - yes/no" buttons
but also it destroy on load
it doesnt go to another scene
did i write it wrong
You'll have to refactor the coroutine in that case i guess, but is there any specific reason why you're using this method of "loading data" after changing scene?
So it seems like MenuManager shouldn't be a DDOL after all. It doesn't look like it does anything between scenes. I think you just want a different object to be the thing loading from the SaveServiceSystem in the next scene
why when I make my build the objcts in my canvas are disordered???
im still confused it as to why it adds the upward force, same code as jump, but doesnt apply a left or right force
Why not have something in the new scene run the LoadFromJson in Start?
Because you aren't overwriting your vertical velocity every frame, just horizontal
Every frame, your X velocity becomes move.x times whatever speed
because if u click start new game in main menu then I dont want it to load data
it doesn't matter what it used to be, it is now that
because save service system script is in game scene and menu manager is main menu scene
Ah, good point. Is there a reason you can't load the data first, then change scenes?
Why do the objects in my canvas move whenever I make a build?
Then just use a bool in DDOL ,
Bool DoILoadData
because save service system script is in game scene and menu manager is main menu scene
When pressing NewGame set bool to false
wait what that does how is that gonna help im confused now
SaveServiceSystem is a DDOL, it should be in every scene
yes but its not in in main menu scene because that is starting point and i only save data from game scene
and then I cant assign player and camera script in main menu
cause they are only in game scene
Keep a bool in save system , for when you want to load data and not
When you press NewGame set that bool to false, and when you want that data to be loaded after changing the scene set bool to true before changing the scene
And in the new scene inside the start load data if that bool is true, otherwise not
Why does your save system script need to reference other objects instead of having those objects tell the save system what to save
Yes I know I should have changed that but this was easier way and I understand it more I dont think I will know how to convert it to player script and cam script to tell save script what to save
save system in my game does not care what the data its saving is, the data just needs to implement a interface and be passed in
#💻┃unity-talk
And explain what that means
you maybe havent set canvas scale with screen option
and make it 1920x1080
i guess
Right now you have what we in the 'biz refer to as "A gigantic pile of spaghetti".
You have so many things referencing each other and those references referencing other references that reference the original reference that your entire codebase is a big pile of tangled noodles.
yes haha i understand
You're gonna need to really learn how references work, and how to work with singletons, and re-do a significant portion of your infrastructure if you want to be able to save and load data
otherwise any time you intend to add anything, it's going to necessetate changing dozens of scripts
but can I somehow make it work as things are set now
so if Im changing the velocity in fixedUpdate, all movement based logic should be contained in it including dash, even though its a one time thing ?
Can i get help with something? I am making a database for a leaderboard and I want make it to that when the player dies their user and score is input to the leaderboard. Everything ive tried so far isn't working?
cuz I added this to FU() but its not working either:
if (isCrouching)
{
rb.velocity = new Vector2(move.x * crouchSpeed, rb.velocity.y);
}
else if (isDashing)
{
rb.AddForce(new Vector2(move.x + dashSpeed, rb.velocity.y));
}
else rb.velocity = new Vector2(move.x * walkSpeed, rb.velocity.y);
because Im not really making complicated game, I will probably have only this options to be saved and maybe health
can I?
what have you tried
Rework your save system so that it exists in all scenes and does not reference any game objects.
Have the objects in the new scene get their starting data from the save system when they're created.
Then all you need to do is tell the save system whether or not to load the JSON before changing scenes and everythign will be in place
Okay I will try
but in which method should I put that, for example now Im doing that camera reference save not save reference camera but idk where to put that in which method
like i mean do I put it in void start etc
cause if I put it in void start it will at the start of game scene tell to load camera data and I only want it to load data if player pressed Load Game in main menu
What does this script need to read from the save system
so here for example I need camera max/min pos and camera pos to reference save
And this code is on your save system, right?
this one yea
and I need to convert all of this to player script and cam script
so they reference save not save reference them
So don't do that. Instead, in start, have camController check this object, and set its own minPos and maxPos to whatever this object has in data
okay and where to tell it to save
And make the save system default to the values you want minPos and maxPos to be when you start a new game
Where do you currently tell it to save
I meant to load not save sorry, I save my data trough button in my game scene
I meant where to tell it to load camera min/max pos and its normal pos
You'd load the data from the JSON exactly as you currently are
You have the camera get its minPos and maxPos on start. They'll get whatever data the save system has for it
If you've loaded the JSON, it'll be the data from the JSON
If you haven't, it'll be whatever default value the save system has
yes but u said to remove reference for camera and player
Correct
The save system should not reference the camera or the player
yes
Those objects should get their data from this object
which can be referenced from anywhere
I just delete this lines
because it's a singleton
Yes, and have the camController set its own minPos and maxPos in start, based on this singleton's data
yes and then I do SaveServiceSystem.instance.data.camMinPos = minPos;
in camera script
for example
This would save the camera's minPos in the singleton's data
Is that what you want to do
well when I click Load Game in main menu I want it to load: Camera min and max pos, camera position where it was last saved, player position where it was last saved and death count
so yes
and then I would do same for maxPos and its position and then similar thing in player script right?
Which you are doing by loading data from JSON, correct?
yes like this
SaveServiceSystem.instance.data.camMinPos = minPos;
right?
wait sorry
minPos = SaveServiceSystem.instance.data.camMinPos;
like this
so that would set its minPos to last saved data
The one you want to set is the one on the left of the = sign
that's the value that changes
[Thing to change] = [Value to change it to]
yes
minPos = SaveServiceSystem.instance.data.camMinPos;
like this
but i still dont know where to put that line of code
in my camera controller script
i cant put it in start cause I dont want it to load everytime u start game only when u start game by load game button
making a custom url to input the username and score and then to add that to the database
why a custom url ? wdym by that. Also is this local or web
int count = Physics.OverlapSphereNonAlloc(transform.position, range,_colliders,mask);
Debug.Log(count);
``` my overlapSphere isn't detecting my player. the player tag is in the mask and the player is tagged :C
tag and masks are completly different things
I mean it has the layer mb
web, have some code that allows me to input smth into the database using a url, so i tried to add it to the unity that it will set the username and score
its working now i believe
you should iterate through the count and see what was hit
i just need to make the leaderboard
yes
also you can draw the gizmos
see make sure its where you think it is too
I did
show it
Unity already has one if you're doing web.
when my player falls in it won't detect it
whats the issue? cant find the OP
overlap not detecting Player
ahh, classic
not seeing something obvious 😢
thats looks like the gizmos to me oh nvm
this is the entire update
protected virtual void Update()
{
int count = Physics.OverlapSphereNonAlloc(transform.position, range,_colliders,mask);
Debug.Log(count);
for(int i = 0; i < count; i++)
{
Debug.Log("found Collider");
_objects[i] = _colliders[i].gameObject;
CustomGravityObject gravityObj = _colliders[i].GetComponent<CustomGravityObject>();
if (gravityObj != null && !influencedObjects.Contains(gravityObj) && gravityObj.enableCustomGravity && gravityObj.isGravityStateAccepted(gravityType))
{
AddGravityObject(gravityObj);
}
}
foreach(CustomGravityObject gravityObj in influencedObjects)
{
if (!_objects.Contains(gravityObj.gameObject))
{
RemoveGravityObject(gravityObj);
}
}
}
i bet that's a CharacterController which is technically a collider but I don't think they show up in raycasts/queries
nah, capsule collider and rigidbody
ya, triggers are the only thing a CC will activate
show the collider
show the player
and what layer is this object in?
Player
yea show the entire inspector plz
it's the parent
note this appears to be a child of the above
and the hierarchy
Then what's teh "Capsule" object?
sorry if we seem to not belive u..
this is the mask
Ok and where is this overlap query located? Is it the yellow thing? The player doesn't seem to be inside that
when I click play the player falls into it
how when its so far lol
ok welp, idk
now I want to see the capsule enter the Sphere Gizmos!
unless ur overlapsphere is super small
the overlapsphere and gismo use the same range float
i know right.. its like u gotta cover all bases
is the position the same?
ye just transform.position
does it matter that it's being called as base.update() from a script inheriting this?
but is this centered up on the planet graphics?
it shouldn't cuz the debug.log is being shown

how? xD do I screen record or just a screenshot of when it's in there?
whichever you can, video would be easier
make sure ur not reading any older Logs
Looking for a free online video recorder? Check out this app. It’s a free screen recorder with no download required. You can grab any screen with audio and record yourself with a webcam.
heres one that records from ur browser..
dont have to download anything.
I got obs
^ oh well use that
ShareX is better 😛
shareX = little files
OBS = big ass files
true, in OBS yu can just reduce the filesize too btw
ya, but thats a hassle..
it's only a couple seconds

at this point i'd say isolate the code...
make a new gameobject.. with just that single overlap call
I'll try with normal overlapsphere
doubt that will make difference
there is prob something very obvious we're not looking at 
when i run into an issue like this where i can't explain it.. its normall the system as a whole.. something in the system interfering... and i prove that by making a simple gameobject/ simple script with just the part thats broken and see if that registers the thing
probably.. but i dont see it
he has a rigidbody.. its not kinematic.. its on the root GO, the mask is Player.. the layer is player.. the collider is sufficient size.. the overlapsphere originates from planets center..
ahh is the mask field correctly assigned there?
wait what do u mean. this one?
one possibility is the transform.position is not centered to the planet u think it is
(that would be if the graphics were off-center of the parent) or w/e
but if ur drawing gizmo's from teh same point i dont think thats it either
you shown PlanetGravityAttractor but log is coming from GravityAttractor
but could u show the planet test uncollapsed, and the inspector
or is that because its inherited
ye
Hello, nullable bools?
public IEnumerator SetOverheadEmoji(string input, bool? isAnimating = null)
can I use this to do
while(isAnimating)
was that always there?
that's with the normal overlapsphere
this doesnt have anything to do with it does it
nullabale u need .value
oh wait nvm u asked something else.
normal overlapsphere is getting a count of 2 and then goes into the code I guess with an entry of null
I thought as much but im not sure how that works, .Value == true?
interesting
if you want to know tru/false yes .value , otherwise yes for null check the var itself
good call using that method.. atleast u know its positioned correctly
what two colliders does it get?
does it get its own collider?
what's the question here? am curious
Ok thankyou kind sir
oh maybe capsule and the ground check trigger
u can scroll back up to see... OverlapsphereNonAlloc not detecting player..
keep in mind you need to check HasValue before checking value..
ye I checked, it's the capsule and the trigger
yea, thats probably it.. the ground check.. sooo aparently now regular Overlap does work
but NonAlloc doesnt?
yep
Hmm how come?
are you sure u allocated enough size?
it has a size of 10
his layer is assigned correctly.. the mask matches.. the player has a collider has a rigidbody.. its not kinematic.. it does make contact.. but doesnt register a hit
I set them to a new array in start
How big is the radius?
15
if you have a nullable bool and it is null, .Value will throw an exception, so make sure you handle the null state properly
he says he uses the same variable for the gizmo..
Ahh ok so I should be ok if im running other code when it is null?
if (isAnimating == null)
{
for (int i = 0; i < animatedThinking.Length; i++)
{
overheadEmoji.sprite = animatedThinking[i];
yield return new WaitForSeconds(0.8f); // Wait for 0.8 seconds
}
}
else if (isAnimating!= null)
{
while (isAnimating.Value == true)
{
for (int i = 0; i < animatedThinking.Length; i++)
{
overheadEmoji.sprite = animatedThinking[i];
yield return new WaitForSeconds(0.8f); // Wait for 0.8 seconds
}
}
}
just sanity check gizmos and overlap are in the same script yes?
baffling
Did they already show the LayerMask to make sure it's correct?
take the performance hit and use regular overlap? ¯_(ツ)_/¯
I could but... learning is good and either I did something wrong or there's a bug in Unity
lol, im not seeing the issue..
most likely me doing something wrong xD
Debug.Log(count, gameObject)
make sure it is running from the correct script just in case
i agree but i wish i could tell u wat
Bc the only difference is that nonalloc needs a collection provided. It should work correctly . . .
yeah they should work the same
Do you have the code posted to look at? I want to check the collection used . . .
use a paste bin site
!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.
show us the entire code..
That's why I want to see the collection implementation/setup . . .
yea, maybe with the entire code block something will stand out
me and nav are not seeing it
wait...
uh oh
did u rubber duck urself?
nice
lol.. bro
😄
i want my 10 minutes back

I want it + interests of 35%
had a funny feeling inheritence had something to do with it
wait nvm the ohno, start wasn't virtual
me too.. b/c nothing else made sense
I figured smth was amiss with the code. It all comes back to the code . . .
yeah good call on that
Once they mentioned calling base. Smth was missing a base call or access to the base method . . .
soo.. whats the fix?
Right, right? 😄
enlighten me.. as someone not familiar with inheritance
making the start virtual and call its base method in parent
make start virtual -> call base.Start() in the inherited class' override start
They did not make Start virtual so it can be overriden and call to the base method . . .
ahhh, cool cool TIL
antother reason I usuaully stick to composition when possible 😛
you know better.. shame
lol! j/k glad u figured it out 🙉

actually... lets thank the rubber duck
rubber duck OP
always is
but plz still buff
facts
i've never had an issue with comp
right 😄
much easier to debug imo
u damn near need breakpoints everywhere to debug an issue with inheritance
(atleast i would)
yeah and sometimes you want to use abstract methods because you want child classes to do something parent only defined
but then you mind as well use Interfaces
when using Instantiate to spawn a GO in the world the scripts that are attached to it, Do their constructors run?
interfaces im cool with
interfaces I've only recently learned
if the object is created yes
even inheritance im okay with.. as long as im not overriding stuff
yup, thats how i initialize starting values and stuff
if you mean like
public SomePlainPoco somePlainPoco
Unity will init this but only if its serialized in the inspector (assuming you meant scripts with constructor like poco)
who summoned me?!
yeah on Instantiate Awake, Start OnEnable will be called
class x
public X {
variable assignments here
}
?
this isnt C++
Scripts attached to GameObjects derive from MonoBehaviour. A MonoBehaviour does not have a constructor . . .
oh also no constructors on UnityEngine.Object stuff
but like, Awake, OnEnable immediately (in most cases) and then later Start
use Awake Start and OnEnable
yup
Each Awake / start/ update is associated with thier own specific object and not hte class in general
jsut a side effect of how components are done you cant use the constructor directly
yes they are instance methods
right they're instances
@crisp anvil if you want to activate or setup a script on a GameObject, use its Awake, OnEnable, or Start method . . .
https://docs.unity3d.com/Manual/ExecutionOrder.html
the order all the messages are called in
we got both Awake and Start so you can make some assumptions
generally Awake setup your internal state
in Start you can assume everyone else has run Awake and setup external stuff
there is also this assuming you use poco
public class SomePoco
{
public string Something = "";
}
public class Foo : MonoBehaviour
{
public SomePoco somePoco; // will get new() automagically
}```
same with Lists/Arrays
Awake = internal
OnEnable = switch code on
Start = external
OnDisable = switch code off . . .
That is good to know, I tried using the new keyword and monobehavior didn't like it
yup, you cannot new components since they're UnityEngine.Object
public class SpawnerScript : MonoBehaviour
{
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
SampleClass sampleInstance = new SampleClass(42);
sampleInstance.Initialize();
}
}
}```
```cs
public class SampleClass
{
private int storedInfo;
public SampleClass(int info)
{
storedInfo = info;
}
public void Initialize()
{
Debug.Log("Initialization method called.");
}
}```
i also just usually use an Initialize method. that i call right after i Instantiate..
if its a regular monobehavoiour
Yeah I usually have Init methods because to reset games I prefer not to reset the whole scene + other reason ofc
ya, i have setups where i need to know who spawned it..
but i havent figured out a better way to do it.. than to use an Init method..
but that may be the best way..
yeah I think it's a reasonable way to do that
neat, no refactor for me!
ive slowly starting using Non Monobehaviours for data type stuff..
but it sketches me out tbh
not sure when/how imma break something
when you do anything outside of Unity you cannot help it but use pocos
hey, best way to learn is to break things in various ways! 😛
feel like tons of my code was always structs and regular classes
Init methods are great for MonoBehaviours. My problem is naming some Init and others Initialize. OCD issues . . .
thats why i have backups of backups.. and more backups
you mean git, right? 😄
Init = Pro
haha, git should be pretty much enough 🙂
(given that it is both local and non-local)
yea but ive had conflict errors that fuckd up my entire project
thankfully i had local zips
I use Git but keep a backup on an external hdd. You never know . . .
like once.. i had a git that i tried to push.. and it would get to 99 percent and just fail
its always possible to fix a issue on git with conflicts
me when I accidentally purged my last 5 commits
aye! ME TOO
i have somethign in common with the mighty Random!
I have a particular repo that I'm not sure about.. I'll pass on the errors next time im fiddling with it..
perhaps u have the magic touch to help me out
I hardly commit or forget to. I guess I haven't lost enough to commit fully, though I do recommend it to everyone . . .
its not really a conflict as more of a failure to push/pull
at work we got a few vcs systems in use, but code is pretty much just git, then a monthly backup of the server the remote is on runs
we do use perforce for the artists though instead of git. draw a very hard line vs source art and gameready art
i learned github during a gamejam.. it was a terrible experience 😄
That's what I hated the most; losing art from failed drives. That shit made me quit. I do miss making 3D art . . .
This is a very stupid question but I can't test this in-game now, can you attach multiple identical scripts (as in, the same script) on the same game object?
yes as many as you want
Yep . . .
But they're harder to distinguish from if attempting to access an individual instance with code . . .
How would that work when you're calling it with GetComponent?
It's easier to create separate variables and assign them via the inspector . . .
exactly , you would need to link directly in inspector
otherwise no guarantee which one GetComponent grabs
i think the one added first but never tested that, just assuming lol
I did run a test and it grabbed them in the order added, but if you manually reorder them from the inspector, I believe they will retain their original order . . .
Don't think I'm ever gonna need to call that script, just going to be an ammo pickup and I don't want to make an entirely new script for picking up an object with multiple ammo (like the backpack from doom)
ah yeah so its kind of like how InstanceID works ?
But multiple runs could yield different results . . .
I'd like to think so . . .
you mean its like kind of like a Tag?
why not just make an array instead of multiple scripts
you could ^ yea
Hm, could work
would be much better
at least thats what I got used to making my Data be SO
why are the backpacks changing their content during playmode
A backpack with different types of ammo sounds like an array of SOs for each type of ammo . . .
yeah thats exactly how I do mine ^
It's a general AmmoPickup.cs script, not a specialized BackpackPickup.cs script
it can be an array regardless.. and you can tell if its backpack if contents > 1
I don't see the point in copy pasting the ammo pickup code just for one item
you dont need backpack seperate script is what Im saying
Why do all of that instead of making a list though?
When you create the array variable, you can pick the size/add the amount of different ammo. If the backpack does not change the number of ammo during runtime, an array is fine . . .
yur ammo pickup script can be both . And your player can tell if its backpack if contents of list ammo types is > 1
yes since they're placed at scene
This is what leaving unity for 6 months does to a mf
when im walking up a slope on the side im not walking forward but also to the side, why? cs moveDirection = orientation.forward * y + orientation.right * x; slopeMoveDirection = Vector3.ProjectOnPlane(moveDirection, slopeHit.normal);
slopeVelocity = Vector3.ProjectOnPlane(rb.velocity, slopeHit.normal);
if(slopeVelocity.magnitude > moveSpeed)
{
float a = slopeVelocity.magnitude - moveSpeed;
Vector3 o = -slopeVelocity.normalized * a;
rb.velocity = rb.velocity + o;
}```
```cs
rb.AddForce(slopeMoveDirection.normalized * acceleration);```
if you had dynamic things like chest then yes something not-fix would make sense, like dictionary or list
just wanna say, i like the debug panel... that's how I design my Controllers..
yeah i gave up on it after some time
lmao
i need to put other important stuff on there
I should start using UI more often, I got into a bad habit of using OnGUI
i just increased the friction and it helped
I just make my variables public/serialize them, and track them in the inspector
haha yeah I remember those days too
I still do just use inspector for private vars though by using Debug mode
lol, i just like seeing the data move around
Yeah i do that with OnGui it just doesn't look as neat as canvas 😛
public void OnGUI()
{
GUI.Label(etc..
}
I dont have to create like 1000 diff things and link them inside inspector, each script has their own debug
i think it just depends..
if ur in code.. and just wanna see the variables OnGUI is fine.
but if u wanna show it off or juice it up.. UI all the way
oh yeah def just for debugging. Never for the Player 😛
what does the "SO" mentioned here refer to?
i need the friction to be set to 1 which is the max
but thats only for walking
and i also need the friction to be 0 to block the player sticking to walls
what do i do
ScriptableObject . . .
hehe
seems like an ez fix with some if else statements
speedometer for player, I dig it lol
yup, never made it into a game or anything.. just for debugging.. but it felt sly
if (isWalking)
{
friction = 1.0f;
}
else if (isJumping)
{
friction = 0.0f;
}
else
{
// something else maybe
}
playerRigidbody.drag = friction;```
i already do that
would be pretty neat for a speedrunner game
but i cant do that
for the walls
im thinking of adding a second collider
for only half the player
from the middle going up
like a wall collider?
yeah
making it like 0.01 bigger than the normal one
so u wont really notice it
with 0 friction
but i'd also have to scale it properly with the actual one
dont know how to fix this issue where one set of my drawers moves correctly using DOTween however the other one on the opposite side moves weirdly, ive tried using localPosition in my script but to no avail
are you sure the pivots are correct
what do you mean?
need to see the pivot of each drawer to know which way to open it no?
baed on the code, the relative orientations of the drawers are different for each chest of drawers
could maybe use a sphere that ignores the player.. but detects walls
GIven that you're doing a local move on the x to -1.5, I would guess you haven't standardized anything
no?
true but then if hes on the floor and against a wall
i cant have him rubbing on the wall
with 1 friction
and if its 0 then the movement against the wall will be sloppy
ahh true.. i didnt think of that
i'll try adding a second collider
can you select one of the drawers in scene mode and show the Pivot point with move tool
Anything more substantial to add? Or is that all?
perhaps?
i dont know what standardizing is
Making things follow a standard
So they are similar to each other
making sure that x-1.5 would work across many objects?
right
yeah select it on Local mode and not in center mode or Global
same thing just moved down
should have containers fitting around the drawers so ur axis' are all the same..
ur still in global mode
the front of the drawer should always be facing the (certain) axis
xd my bad
if its not.. slap it inside a empty container.. rotate it to make it right.. and move that container instead
so -x is correctly going inwards, you need + X
is there a way i can check if i need - or + based on the orientation?
thats the hard way
perhaps store on each object what their open direction will be
or that ^
could use a vector3.. +1, 0, 0
would be the opening direction..
-1,0,0 for the other way
unless you wanna go through each thing that opens and fix it with pivot parent or blender
no thanks
if its just one so far.. that wouldnt be so bad
blender is cancer
fixing pivot is easy in blender but sure lol
everything starts with block 😄 lol
personally all my drawers are so the Z is always forward this way there is no second guessing but yes its time consuming
blender is really powerful. but i understand beginners not wanting to deal with it
They aren't saying to make anything, just reexport with the right orientation
now i gotta do the scaling
i hope having two colliders wont be a problem in the future
lmao
iirc you dont even need to rotate, just export it with the Apply Transforms for FBX
lol... legit concern tbh
The Donut tutorial is hands down the greatest tutorial for any piece of software I've ever seen. It teaches you the program, not how to make whatever specific thing you want someone to make for you
okay
ya, theres not much it doesn't show u..
if he animated a chunk being bit out of it.. it'd be the ultimate blender tutorial
gamedev is problem solving, you need to figure out this one has many fixes
There's a reason basically every 3D animator knows about The Donut.
you could just make an empty parent on each drawer with correc Z
if it were me id use Nav's suggestion and have a orientation vector and just change that in the inspector depending on ur drawers
or throw them inside an empty container.. and make that face the right way instead
two solid solutions
theres a cheeseburger one too.. that teaches you procedural texturing
thats the 2nd best one ive ever seen
could someone help me always center and scale this collider accordingly to the one above?
copy values and paste?
Does anyone have any idea why my rigidbody would be moving way slower backwards than it does forwards but not have that issue when going left/right with this? They should be identical...
btw u should not use Time.delta time inside AddForce
ok
try combining it into one call
ok
is there a way to see the version history in visual studio code?
where does forwardInput come from
ya, u have to change the center variable on ur collider when u do such things
I tried this and it didn't work
dang. btw forward is missing speed
Oh I meant to get that in the screenshot mb it's the same as the horizontal one
Just share the full script, and not with a screenshot
!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.
Not seeing anything in this code that would cause it. It would be from something else probably
anywy Update should not be used for physics
in a list when you remove at entry
Listname.removeat(5) for instance
the list collapses on the deleted entry.
I save that index point at the GO's creation so the saved Index's for each GO after 5 will be wrong 6 will be 5 and so on. What a good way to update all the ID's?
any better way than
in a method
for ( int 1 = 0, i < Listname.count; i++ )
{
listname[i].id = i;
}
?
If you find the need to do this, there's something fundamentally wrong with your approach
don't use the list index as an id
What should be used for physics instead if not update?
FixedUpdate()
and if you need to look these things up in the list from some ID, you should be using a different data structure, like a Dictionary
FixedUpdate is for physics
I apologize, let me rephrase, I don't use it as a ID however I use a int called IndexReference that stores the GO's index.
yeah this means you're using the position in the list as a reference
don't do that
store a different kind of ID
oh ok
ok I'll move it there and look through the other scripts 
also show the inspector for this gameobject
are you sure maybe you didn't animate the transforms by accident or something maybe overriding it
in HandleHeight i need to set the height and center of wallCapsuleCollider accordingly```cs
public CapsuleCollider capsuleCollider;
public CapsuleCollider wallCapsuleCollider;
private float defaultHeight;
private Vector3 defaultCenter;
private float defaultWallColliderHeight;
private Vector3 defaultWallColliderCenter;
private void Start()
{
//Height
defaultHeight = capsuleCollider.height;
defaultCenter = capsuleCollider.center;
defaultWallColliderHeight = wallCapsuleCollider.height;
defaultWallColliderCenter = wallCapsuleCollider.center;
}
private void HandleHeight()
{
float targetHeight;
Vector3 targetCenter;
if(isCrouching)
{
targetHeight = crouchHeight;
targetCenter = crouchCenter;
}
else if(isCrawling)
{
targetHeight = crawlHeight;
targetCenter = crawlCenter;
}
else
{
targetHeight = defaultHeight;
targetCenter = defaultCenter;
}
capsuleCollider.height = Mathf.Lerp(capsuleCollider.height, targetHeight, heightDuration * Time.deltaTime);
capsuleCollider.center = Vector3.Lerp(capsuleCollider.center, targetCenter, heightDuration * Time.deltaTime);
wallCapsuleCollider.height = ;
wallCapsuleCollider.center = ;
playerModel.localScale = new Vector3(playerModel.localScale.x, capsuleCollider.height / 2, playerModel.localScale.z);
playerModel.position = capsuleCollider.bounds.center;
}
the wallCapsuleCollider has an offset
bottom is wallCapsuleCollider and top is capsuleCollider
I tried setting the speed in the function I sent to zero and it didn't at all so I don't think anything else is making it move.
not moving it per say but maybe holding it back? but its prob something else, im not sure cause I havent seen/experienced the problem
since you said it moved slower?
public static bool RemoveNPCByID(int id)
{
NPC npcToRemove = npcInGameList.Find(npc => npc.npcID == id); // find npc id in list
if (npcToRemove != null) // if found remove
{
npcInGameList.Remove(npcToRemove);
return true;
}
return false; // didn't find for some reason
}
With this i can do it without storing a index. Better solution ?
Oh I think I found the issue it was in the script I used for turning the gameobject
I don't know why, but this snippet of code for a moving platform I made just does not work. The issue is that the character doesn't stick to the platform; it always slides off and doesn't stick to the platform like I want it to. What's supposed to happen is that the character gains the velocity of the platform in order for it to move along with it at the same rate. However, this isn't working. I even disabled the friction portion of my character controller while the character is on a moving platform, but that hasn't fixed anything. All collideable objects in my game have a Friction: 0 PhysicMaterial attached to them (on their colliders & rigidbodies).
time += Time.deltaTime;
Vector2 movementVector = targetPosition - initialPosition;
movementVector.Normalize();
rb.velocity = movementVector * time * velocityMultiplier;
Debug.Log(playerRB.velocity);
if (checkForCharacter())
{
playerRB.gameObject.GetComponent<CharacterController>().negateFriction = true;
playerRB.velocity += (rb.velocity - previousVelocity);
}
else
{
playerRB.gameObject.GetComponent<CharacterController>().negateFriction = false;
}
previousVelocity = rb.velocity;
Context:
- This is a 2D game.
- This is all running in
FixedUpdate. checkForCharacter()checks if the character is standing on the platform (this function works 100%).previousVelocityis just a variable to keep track of the platform's velocity in the lastFixedUpdate.- The platform moves to the target location as intended.
Besides the fact that you're finding the npc twice, it's fine unless the list somehow get's massive
I'm guessing CharacterController in this context is a custom script of yours?
anyone?
Yeah, it does have the same name as something else though...
It is a new script though.
I’ve been reading about it for three days, but I haven’t had the chance to sit down and code yet… am I correct in understanding animator velocity is available without using a RigidBody?
what is "animator velocity"?
I want to disable a script after it finishes running. If I know the name of the object that has the script, I can turn it off.
GameObject.Find("Cube").GetComponent<ScriptNameHere>().enabled = false;
But I don't want to hard code "Cube" because this script could be attached to other objects as well. What do I replace "Cube" with to select the object that the script it associated with?
i’m animating an object under a rigid body so I can’t add another one, but I’m trying to get its velocity and Google is saying animators have a velocity and angular velocity
a public field where you drag and drop the reference into in the inspector
I wanna know if they’re internally dependent on a rigidbody still
public ScriptNameHere example;```
Yes, Animator motion/velocity is entirely different from rigidbody motion/velocity (and not compatible)
A gameobject can only be controlled by an animator or by a rigidbody at any given time
Is it safe to guess that they still read essentially the same? 👀
If someone animates a sword to move in a direction, and then you moved it that way with a rigid body instead, would you still get generally the same information?
They have nothing to do with RIgidbodies, no
It's probably talking about when using an animation with Root Motion
Yeah it says to enable that 😛
Indeed the docs even mention root motion https://docs.unity3d.com/ScriptReference/Animator-angularVelocity.html
I added "public ScriptNameHere example;" on the outside.
Why are you writing GameObject.Find and all that other stuff?
All you need now is example.enabled = false;
I took it from a snippit on stackoverflow
You need to think about what the code is doing
you are blindly copying things without understanding
that's not a good way to learn
A better way to learn is to go here: !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Thanks for your help.

What says to enable what?
Root motion is a vector represention motion baked into a root transform of an animation clip
It can be applied into a rigidbody, a charactercontroller or a transform
All three work in different ways so depending which one you use Animator.velocity may also return different values
But it really depends what your setup is like
If your animator is correctly giving the rigidbody forces via root motion maybe it'll return the value you expect
without seeing the player movement code this is only a small piece of the puzzle
🤔 there’s a lot of things I don’t know here since I have yet to ever mess with this before, apparently. The documentation just says that you can get those values from the animator if you tick the box- not much explanation on all this depth you’re teaching me on :3
I don't know what part of the documentation you're referring exactly to when you say "those values"
I have a rigid body and an object that is a child it that is animated by players that use one platform out of a game that supports multiple different platforms, so I’m trying to get the animated object’s velocity when animating but use the parent RB for the other people
If ticking to apply root motion passes the values to the rb anyway then I guess I can just leave it on
My issue was that the items weren’t having very good gravity physics when apply route motion was enabled, and the objects aren’t held, so I’ll probably just toggle that on grab
And pray that that works 🙏
the code that i need to send is quite long and might create quite an annoying text wall, so...
this is only the horizontal movement as it's the most important
https://hastebin.com/share/fecobenihu.csharp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
if you're going to share a script in a paste site why not just share the whole thing?
i mean yeah you're right
https://hastebin.com/share/bodiyoxubu.java
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
why does it say java...?
anyway it looks like this code is specifically adding forces to try to get the player to the specified "target" velocity. This will easily negate whatever you're doing in the platform script.
could someone help me out with this?
i need to set the height and center of the wallCapsuleCollider accordingly to the capsuleCollider
and the wallCapsuleCollider has a different height and center
it's really not clear what the relationship you want to have between them is though
top is capsuleCollider
bottom is wallCapsuleCollider
sounds like you probably want a remap function
what is that?
e.g. remap(capsuleCollider.height, minCapsuleHeight, maxCapsuleHeight, minWallHeight, maxWallHeight)
pretty sure you do
Isn't this supposed to return an int?
i've already got all the values
no it returns a float
just dont know how to use them
there's a separate RountToInt
by plugging them into a remap function
I'm facing a strange problem:
In Start() I set enabled = false. But it seems that Update() gets still executed once before Start() finishes its execution and disables the script.
How come Update() gets called even once if I have enabled = false in Start()?
Start runs as part of the first update process
So yeah it's still gonna happen
Can you use Awake instead?
What do you mean? I need something that runs before Update(). Does Awake() run before?
I don't want to start messing with constructors, because I think MonoBehaviour doesn't want that.
Awake runs earlier than Start
Is there a way to change the color or alpha of a 'Tile'?
public Tile tile;
Can anyone explain to me why this doesn't work? I'm attempting to make text flash on and off till E is pressed.
Help would be greatly appreciated (;´д`)ゞ
gotta make it a coroutine
nope
unless you play around with a timer and some if statements
but that's messy
just learn how to make a coroutine
public void Update()
{
StartCoroutine(myUpdate());
}
IEnumerator myUpdate()
{
all your stuff here
}
Yeah, that but with a few additional stuff if you don't want a massive bunch of coroutines playing at the same time
Update is not needed
Can be placed within Awake/Start and looped
well more some problems are better suited to coroutines and some update
my tilemap continues to work like this, it just lets my player go around on mass tile walking, then inside the tiles, he disappears... any idea how to solve this problem?
Thanks I tried this, there's no more errors but the component doesnt become enabled or disabled. Any idea why?
How can I make a script that can change the mesh from a sphere to a capsule or vice-versa? so far I have been able to identify the mesh filter component but not much else
change the mesh the filter is pointing to
myMeshFilter.sharedMesh = whatever;```
right when the waitforsseconds ends youll have to be basically be frame accurate on pressing 'E' . I would move this logic
Ah okay Ill move it into Update() . it doesnt blink on and off though weirdly
sharedMesh, got it, but how do I specify which mesh I want? Just putting 'Capsule' wont do
reference them in the inspector
Mesh is a kind of unity object.
public Mesh HappyMesh;
public Mesh SadMesh;``` for example
It's just like referencing a material, or a prefab, or whatever
Yep, it's an asset like anything else
ohh i think i know what you mean, cheers
UI_transform.pivot = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
hey does anybody know how to change the pivot by the mouse position? I tried doing it but it just flies off the screen.
What does "change the pivot by the mouse position" mean?
im trying to make the pivot of a ui object the same position as the mouse
well according to the docs pivot is normalized, so you can't just directly pass in screen coordinates
i.e. 0.5, 0.5 is the center of the object, no matter where it is
you need to convert the screen space position of the mouse into normalized coordinates within the object
is it 'active' when you hit play in the unity editor? becaause if you start when active is false, then it wont go into the while loop
i see, thank you
do overrided methods always do whats inthe base method too?
no
they replace the base method
It's not ticked in the hierarchy, does that stop the loop?
so do i need to do base.Method?
if you want to call it, yes

