#💻┃code-beginner
1 messages · Page 661 of 1
sure 1 sec
use !code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
A tool for sharing your source code with the world!
Can you go to Edit -> Project Settings -> Input manager -> Axes and show a screenshot of your Horizontal axis, like this?
Yeah good next step
Debug.Log($"Horizontal input is {horizontalinput}");
And make sure Collapse is turned off in the console
do you have any gamepads or otther devices plugged in
do you have any other keyboards you can try?
no but i think its not about keyboard
because i was using this code before its was working
i dont know what i change but its not working now
You can also try restarting Unity and/or your PC
lets try
does this stopping happen anywhere else in the scene? like for an example if you place your character somewhere else and move them there
could be a nasty little collider
i restart my pc still the same and its happen in everywhere
but this thing also broke my dash
i still can dash but not going anywhere
can someone ACTUALLY help me instead of directing me to a video? ik its basic stuff but I have trouble with basic stuff sometimes and for some reason, the more complicated stuff makes more sense to me
i will try to upload short video to yt
this really sounds like what happens when you have a rogue joystick plugged in and leaning ont he stick
I removed everything that deals with jumps so I can start over on that front
using UnityEngine;
using UnityEngine.InputSystem;
[RequireComponent(typeof(CharacterController))]
public class PlayerController : MonoBehaviour
{
private float speed = 0f;
private float TurnSpeed = 100f;
private float xRotation = 0f;
private float yRotation = 0f;
public float SensitivityX = 10f;
public float SensitivityY = 10f;
private Vector3 PlayerVelocityVar = Vector2.zero;
private Vector2 MoveInput = Vector2.zero;
private CharacterController playerController;
[SerializeField] private float playerSpeed = 2.8f;
private float jumpHeight = 1.0f;
private float gravityValue = -9.81f;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
playerController = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update()
{
PlayerVelocityVar = new Vector3(MoveInput.x, 0, MoveInput.y);
playerController.Move(PlayerVelocityVar * playerSpeed * Time.deltaTime);
float mouseX = Input.GetAxis("Mouse X");
float mouseY = Input.GetAxis("Mouse Y");
xRotation += mouseX * SensitivityX;
yRotation -= mouseY * SensitivityY;
transform.localEulerAngles = new Vector3(yRotation, xRotation, 0f);
float rotateX = mouseX * SensitivityX;
float rotateY = mouseY * SensitivityY;
transform.Rotate(rotateX, rotateY, 0f);
}
public void OnFire(InputAction.CallbackContext context)
{
}
public void OnMove(InputAction.CallbackContext context)
{
MoveInput = context.ReadValue<Vector2>();
}
}
Do you have an actual quetion or issue you would like help with/
when input goes -1 or 1 to 0 i just stop holding the key for show its not working even i stop holding and press again only fix its press negative way then press again
have you made any changes to that Input manager window at all?
no
I wanted someone to teach me how to make my character jump
we can't help you better than the tutorials i sent you to
they explain as plainly as you possibly can
the tutorial is too slow for me
its my first week in unity i study unity learn website for 5 day 8 hour everyday and pretty good for jump and other things if its feel slow you can just skip the next
its just not clicking
are you trying to speedrun learning? this isn't what you said before about "not understanding beginner concepts"
well its not clicking with my brain
btw you can speed up the video if it's too slow
what particular part do you not understand that you need help with?
what's not clicking for you exactly?
idk, its just not how I learn
so how do you learn?
Can you do me a favor - are you using a Tilemap here?
yes
Can you show the inspector for your tilemap? I'd like to see all the components on it, especially the TilemapCollider and CompositeCollider if you have them
well its easier if I can ask questions, and/or someone teaches it to me personally. I learn by doing and step by step and videos just dont help
well rarely they do
well you can ask specific questions here (ideally in a thread), but don't expect anyone to be your personal tutor for free
if you learn to use existing resources, you will be able to learn much more diverse stuff without being tied to someone explaining it to you
well I was just hoping that someone could help me when I need it
what is that
sure, but you gotta put in some effort yourself
those existing resources exist for a reason
im autistic, my brain is wired differently
Do this:
On your tilemapcollider2d set "Composite Operation" to "Merge".
Then add a CompositeCollider2D component to the same GameObject and set Geometry Type to "Polygons"
pretty sure a sizable portion here are as well ngl
The composite collider merges all the physics shapes in the tilemap into a single collider so you don't get stuck on the edges between each tile.
also, there are existing resources that aren't videos
there are plenty of text guides that are step-by-step
yeah its worked thank you i couldnt fix without you
they are too vague, and dont explain in detail
ok there are very detailed text guides, a lot of them are actually
where are you getting these vague guides from
tutorial quality does vary, if one isn't working out for you just use a different one
have you checked out unity !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
i pointed him there earlier
because it counts the video lengths + estimates how much time you take on doing the exercises
it's usually an over estimate
on "average" it takes 7
why are you questioning it
most of em are over-estimated in my opinion but ya, theres no real answer here
if you can't bother to sit down and learn the basics
then don't bother at all
this goes for anything
in that case I might as well kill myself
Pffff, well, if you can't stand 7 hours of sitting down and trying to understand stuff, you have like no future on any game engine
Sadly that's how it goes
kind of an extreme reaction but ok
there's 2 ways this can go for you
- you do the unity learn stuff or another tutorial, you figure out what's wrong, life good
- you ask someone to give you the answer, you don't know what is wrong, life bad
Is there any wa to make a sharpnen effec
Stuff like university takes years teaching you to be a beginner in the real world. If you have no clue about programming or how to make a game, what did you expect? It's not like you need to spend 7 hours today doing that one course. That one course still won't even prepare you to make a game. You'll just have a slightly better understanding of what the engine can do.
so what does this mean exactly
thats really sad because I have learned things in a week that take most people a year
this is a coding channel. you'd probably be solving this in some shader or whatever else
you learn some things faster than others
it doesn't mean that you'll learn this fast
it took me like, until i was 23 to properly tie my shoelaces
What is the "recommended" way to manage enemies dying in a game? I was thinking 1) global list of enemies, every update it checks the list, or 2) an event based system, the global list subscribes to the enemy's death event. does anyone have tips? I don't have a practical use case, I just want to know for later
Depends on how many enemies are being handled or what you want your enemies to do when dying, but usually events or just do something within the enemy object
🤷♂️ sounds like a fake metric to me but still theres no correlation between that and this. Especially in coding, you may think you learned something then later on realize how it actually works.
I really do suggest learning c# first though outside of unity so you dont struggle with both c# AND unity at once. Theres an intro to c# link pinned in the channel
edgy
The "prodigy cool guy"
Okay thank you!
well seems like you people cant help me so im leaving
we are trying to help you, we can't help someone who won't help themselves
you're too smart for us what can i say
oop he's gone
Help you with what? You just came here like "this tutorial is too long, I am too cool for that" lol
the video speed button in question:
he learned how to leave the server in 5 minutes when most people take years 
these kind of comments really are pointless. theres no point trolling someone who was looking for advice. i was trying to offer them a realistic perspective on things and being aggressive to someone like this is just useless
dont think i was lying there tho, he learns things in a week that takes others years
Will events also make it harder to find errors later? If a lot of things are subscribed to an event
if your goal is just having a list of enemies that are alive, 100% the event based solution would be better. you would only update the list when an enemy actually dies rather than checking every update.
Short answer, yes. Long answer depends on how you handle it
oh ya the update one would always be polling so that would b bad if they're mostly alive anyways
i have a list with all enemies alive and im using C# events for that, on Start() i just invoke the event
never said you were lying. reread what i said
no problems so far
he's probably just a high school guy (or not even that old) that didn't have any real challenges yet
he'll learn to learn at some point, hopefully
yep. but people basically teasing them and being aggressive sure doesnt help
It depends on how everything is setup in your game, but if everything is on a list, and they are just dissabled (cause you are pooling them) you can just have them referencing the list as a manager to do something when they die instead of having events
Cause even if they are very usefull sometimes, you lose track of where the code is going throught if you start adding a lot of events
it really wont. your logic wont really be complex and i doubt many things are going to subscribe to an enemy dying. Like your current use case would be enemy dies -> invoke event -> remove from list. There really isn't much room to actually have an error here.
But did he even ask anything?
he did, it was a very simple code issue actually, but the "i followed many tutorials and none helped" was a big red flag, so i tried directing to the learn resources
though should probably end this topic, it'll clog up the channel
also the alternative to events would be that the enemies manually call some method to remove themselves from the list, rather than checking in update. Basically same performance and same outcome, the difference is events are slightly cleaner. You wouldnt have to write SomeClass.Instance.RemoveEnemy(this) (assuming the list is used in a singleton)
Are they cleaner because the enemies class doesn't need to know about the list singleton class
Is the events solution cleaner* i mean
The thing is, yes, call stuff for events looks more "clean" but then, if everything gets more complex, tracking what is calling what gets harder and harder
But in this case sounds like no issue
yes and plus you might end up having other things subscribe to a characters death so it makes sense to have anyways. Random example but if you want certain enemies to explode on death, you might have a component attached to them to do this. In the class on the enemy, you wouldnt want to start adding logic like
if(explodeAfterDeath != null) ...
because you'd be modifying the class for every feature in the future. this goes against open/close principle in SOLID. it'd be easier if the component subscribed to the death
Tbh, if you have a exploding enemy, you probably want a whole different logic and script rather than just adding an OnDeath do X listener
What? No
I don't think any of the exploding enemies I have seen in games have anything in common with the normal ones other than the very basic components that make an enemy like health, pathfidning and stuff
Okay I see, thanks
Nothing in common except everything that a character is made up of...? Maybe you should consider looking deeper into events too then
If the only difference between 2 characters is one explodes, and you need to rewrite their entire npc class, you're doing it wrong.
You can have a PlayerHealth script on your player object, and I know I've used another gameobject child with an exploding animation to swap to.
I mean having an enemy that is EXACTLY the same as another but it just explodes it's a pretty bad enemy
They probably do different things like try to track down the player, stop briefly before reaching them, maybe tick before exploding.... that kind of stuff
I really dont see a need to continue this if your argument is going to be that my completely random example isnt going to be the best game design.
My argument is... that creating new enemies by raw adding just do X when Y is not a great workflow??
The example was straightforward. An enemy that explodes on death.
You're talking about something completely different
How can I stop a child (that just contains a Sprite Renderer) from rotating along with its Parent?
There's this component called Rotation Constraints, but even after looking at the API I have no idea what it does/how it works.
So if you only want something to move with another object, but not rotate with it, then don't parent it. Instead use Position Constraint on the object, and give the other object as the source for its movement. It will move with it, but not rotate with it
Rotation Constraint is similar, but makes it rotate with the source. Like if you want a compass arrow to point where the player is facing, but not move with the player.
You could add a script to the child object to reference the parent and counter-rotate it. ```cs
using UnityEngine;
public class MaintainWorldRotation : MonoBehaviour
{
Quaternion initialWorldRotation;
Transform parentTransform;
void Start()
{
initialWorldRotation = transform.rotation;
parentTransform = transform.parent;
}
void LateUpdate()
{
if (parentTransform != null)
{
Quaternion inverseParentRotation = Quaternion.Inverse(parentTransform.rotation);
transform.rotation = initialWorldRotation * inverseParentRotation;
}
}
}
What Position Constraint and Rotation Constraint are especially good for is objects that conceptually don't make sense to be children of what is moving them. Like if you can pick up an object, wave it around, and then just as easily drop it, it's easier to do all of that with constraints. Just set the constraint source and enable it when its picked up, and null the source and disable when dropped.
I have a camera that follows the player from above, but when in map view it can freely scroll over the map in any direction, so it made more sense to constrain when acting as a minimap, and then unconstrain when scrolling over the map.
Also when the player goes up and down floors I didn't want it smoothly going up and down with the player. I needed it to snap to the floor the player was on, so that the transition was clean on the map view. So I would disable the Y on the constraint and manually control it.
Rotation constraint should really just be a boolean on the transform component
instead it has to be convoluted with some blending properties which no one uses anyway
I like that it's more than that. Being able to swap sources at runtime is useful
Is there a better way to show that on the editor itself rather than in console??
Like a boolean I cannot interact with?
Thanks for the advice. I ended up using the RotationModule code I already had, but the principle of rotating in the opposite direction to the parent worked.
Sure, just create a script called IsTextValid or TextValid with using TMPro and a property for the text component TMP_Text text; and your bool property, and your code. void Awake() { text = GetComponent<TMP_Text>(); }
Yeah just draw regular label item in the inspector
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/GUI.Label.html
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Editor.OnInspectorGUI.html
a "read only bool" could also be used but better off slapping a label based on bool itself / validation
The what? I didn't catch any of that
Ouh, Imma try that, how does that look?
try it lol its just a textlabel, you can style it as you want
some like this prob
use a ternary to print specific label based on isValid or not, you can even color it green vs red or something
custom inspector here is definitely the way rather than a separate component. you'd probably want to DrawDefaultInspector and then add a label afterwards with the info you want
This is a tutorial on custom inspectors. You really only need the topmost sections, the rest can be skipped.
https://learn.unity.com/tutorial/editor-scripting#5c7f8528edbc2a002053b5f6
Ye, I figured it out
Is it bad to use a lot of interfaces? For example, if I have a projectile, I might make it implement an interface indicating its a pooled object, as well as a projectile interface, or if it's a monster, I'll have it have a health interface, interface to handle its death, etc
Taking for example, the monster health thing - I think it's better to use a separate component that handles health rather than an interface
When you say another component, do you mean like a Monobehavior script?
Ok I see, cuz a lot of things might have health, and it's reusable as a component?
yes
and then you don't have to reimplement the basics of subtracting hp, taking damage, checking for death, etc. over and over
as for having different behavior on different things with health - you could have the health script expose C# or UnityEvents like OnDeath and/or OnHealthChanged
that way the basics would be the same everywhere but you can have a lizard whose tail falls off when his health reaches 5
or whatever
But if you do end up with multiple components with health, interface is a good way to expose it.
that approximation may be less than 0.01
try _moveDir.magnitude < 0.01
that seems to work, odd, since _moveDir is from input
The approximation is something like 0.000001 or less. It's supposed to be epsilon - the smallest value a float can have afaik.
thank you floating points very cool
damn
It's meant to avoid floating point error. Anything above that would not be equal
On SceneLoaded would happen after of before the awakes on the scene?
according to docs Awake -> OnEnable -> SceneLoaded -> Start
Cool then, my thing should work I think lol
do i have to worry about this: NullReferenceException: Object reference not set to an instance of an object
Bullet.OnCollisionEnter2D (UnityEngine.Collision2D other) (at Assets/Code/Scripts/Bullet.cs:33)
line 33: private void OnCollisionEnter2D(Collision2D other) {
other.gameObject.GetComponent<Health>().TakeDamage(bulletDamage);
Destroy(gameObject);
}
its not affecting the game but its sending a lot of error messages
Of course you should be worried. Any error in your could is potentially something broken. In this specific case it might not be affecting anything, but generally the purpose of errors is to tell the developer that something didn't go according to expectations,so there's no telling what effects it might have.
sometimes when i code the prototype, i do it very unorganized for the sake of just getting it done because im very unexperienced to have the intuition on what should be put where. is it fine or do i need to maintain the habit of organizing the code first?
It's really hard to answer these sort of things. Of course organizing better is better. Though we cant just say you should make that a habit if you dont know how to do it better
It depends on what you're coding too. If the foundation of your game is lazily made then well everything is built on a bad foundation. If some obscure 1 time interaction is coded poorly then it's not a big deal
If you plan on extending your prototype to a full game then you should take the time and effort to keep it organised and clean. However this in a way going against the idea of a prototype, at least for me
I at least code my prototypes fast and dirty and if they work out, then I take the time to completely refactor everything into a foundation that will work for production
if anyone could help me out here, im trying to make a small system for a game im doing, and im trying out the UI toolkit for editor panels.
im trying to make a tag system for a game im working on, and im having trouble with the 'testing#' buttons either wrapping properly or the area they are inside of expanding down as i add them
Originally it was just the 2 visual elements at root and while it would wrap, it wouldnt expand downward, and then i made it a child and attempted to do the same, (code is hooked up to properly create buttons in the right visual element) and it wont wrap now.
unity vers - version 6000.0.31f1
thanks for directing me!
This is probably a really easy fix, but I can’t figure out why my camera is so zoomed in on game but on scene it is normal? It also goes over to the side when I try to use a camera follow script and I don’t think the scripts the problem.
You have zoomed the game view 9x. Also https://screenshot.help
quick question: if i need to delay a function (in this case, delaying the gravity to be instantly applied on the player after an air dash), would it be better if i use invoke or a coroutine?
Invoke is simpler to use, but it's much less flexible and gives you less control
In this simple example there's no practical difference but coroutines are better overall
is one more efficient than the other (in terms of processing) in this scenario
Efficiency should not be a consideration at this scale
right
for some reason the docs say that Coroutines provide better performance, although without many details
Because they don't need to resolve a string to a method
They don't need to do reflection or anything
sincerely I never seen anyone use Invoke in a serious project anyway
I am genuinely curious where people find out about Invoke, is it from c# related tutorials?
Probably tutorials yes
I never was introduced to it when learning c# in unity, I've only seen it from other beginners
It's not a c# thing
It's a Unity thing
You can be sure anything beginners are doing came from a tutorial or AI
or unfortunately trial-and-error
(in the case of code with no errors, warnings, or colors)
thanks I just implemented a coroutine, maybe I should play around with gravity manipulation later
I just searched up how to delay a function lmfao
well tbf the invoke function would indeed be the direct answer to that
it's just not a very good way (comparatively) to go about it
because magic strings
that's what i was wondering, since i saw both method and i was thinking oh hey either one works
invoke is good enough but i was asking if i should just do a coroutine and save myself the trouble if i wanted to mess with gravity again
oh and another question
i was thinking of implementing wall running
but my character is using a kinematic controller and most tutorials out there uses rigidbodies to save themselves from the trouble of simulating gravity
how should i approach this
👋
I have an UnityEvent<float> in my code and in Inspector, I'm linking it to a method which only takes a float value
But it still requires me to manually input the value
What should I do?
The event: ```cs
[SerializeField] private UnityEvent<float> onValueChange;
How I invoke the event: ```cs
onValueChange.Invoke(normalizedValue); // the type of normalizedValue is float
The method: ```cs
public void ChangeSensitivity(float sensitivity)
{
GlobalData.sensitivity = sensitivity;
}
How I link the method (see how it requires me to input a manual value):
Perfect, turns out I didn't choose it from the dynamic section
Thank you!
Hi have problem.
i have a track gameobject and on that game object i have script with a variable "track"
i am trying to assign the prefab track gameobject onto that variable but when i click play it reverts to being the gameobject in the scene rather than the actual prefab
I kinda see why, it happens because the variable i am assigning is technically itself. But i want it to be the specific prefab not "itself". How do i fix withouht having to make a gameobject in scene that stores this gameobject prefab then access it through there
seems like waste of time, surely there is an easier way to do it
you're reassigning a variable, but you don't want it to change...?
there is not a good direct way to do what you wanna do
you cannot reference the prefab asset on itself and retain the asset ref
would i have to make a gameobject and just put it on that then acess the prefab from there or would that still not work
its more like it automatically changes to scene view object rather than the prefab
so when i spawn it, it spawns the scene view item rather than the actual track prefab
Anything that sounds about right will probably work, not sure which will be preferable for you in this context
but you just can’t keep the asset reference on itself directly
yeah ok thank you for help
I am following this tutorial, and the clamping for the camera just isnt working at all. It also restricts me to vertical camera movement https://www.youtube.com/watch?v=f473C43s8nE
FIRST PERSON MOVEMENT in 10 MINUTES - Unity Tutorial
In this video I'm going to show you how to code full first person rigidbody movement. You can use this character controller as final movement for your game or build things like dashing, wallrunning or sliding on top of it.
If this tutorial has helped you in any way, I would really appreciate...
I am using this tutorial because its from around the same time as 2021.3.13f
You'll have to show your code
ah, right
public class PlayerCam : MonoBehaviour
{
public float sensX;
public float sensY;
public Transform orientation;
float xRotation;
float yRotation;
private void Start()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
private void Update()
{
// get mouse input
float mouseX = Input.GetAxisRaw("Mouse X") * Time.deltaTime * sensX;
float mouseY = Input.GetAxisRaw("Mouse Y") * Time.deltaTime * sensY;
yRotation += mouseX;
xRotation -= mouseY;
yRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
orientation.rotation = Quaternion.Euler(0, yRotation, 0);
}
}```
mouse input is per frame, you should not multiply by dt
you need to reduce the values set for your sensitivity variables by a factor of like 100
just did, the sensitivity is alright
but the camera is still outside where its supposed to be and only moving up and down with no clamping
okay, now i can look around and clamping is working but the camera still spawns outside
its supposed to be inside for several reasons
its being set to the position its supposed to be in Update(), its positioned there in the editor, yet it just places itself outside
It's a really bad tutorial btw
It says that you have to use the proxy object to set the camera position but there's no reason for that. You can just put the camera as a child of the player and delete the script that moves the camera there
and its instantly working! thanks!
the reason im using it is because it was the only one that covers sliding, dashing, etc.
and the other one that also didnt cover these just didnt work, gravity was bad and didnt react to any changes, etc.
oooooh, thats it!
thank you so much
ok, I try to make my character to move with the input system, and used a small usefull youtube tutorial, but it doesn't work. Can anyone help?
see #854851968446365696 for what to include when asking for help because you have not provided enough details
oh, umm here is the code, errors and input manager settings that i use:
I tried changing the variable's name and capitalization but it still doesn't work.
is this enough information?
You have two PlayerMovement scripts
oh, right forgot about that, let me see if that fixes it
you would think that there would be errors in the IDE, it's clearly configured (despite the god awful font)
I just enjoy pixel art font
Hmmm... i dont see a second playermovement script
oh, wait there is a second script in a folder
great there is the old same error again :[
You're doing GetComponent<PlayerInput> but you named your actions asset that
Which means it's generating a class by that name
This is essentially a naming conflict between the built in PlayerInput component and the one you created that is not a Component at all
Your code also seems to be confused about how it's using this object. You're using it as it were an InputActionAsset but it's not
can you tell me it in english?
That was English
It's hard to say what fix to do because you could go one of two ways
In any case you should rename your actions asset so it's not called PlayerInput because that's confusing the hell out of you
i think i get it
And make sure when you do that it doesn't leave behind the generated C# script named PlayerInput.cs
I am very confused
how the hell are we meant to rotate a quaternion in Unity.Mathematics if "Operator '*' cannot be applied to operands of type 'quaternion' and 'quaternion'"????
I don't see any functions for it on the scripting api
You use the mul function
mul(q1, q2)
tx
Unity Mathematics is modeled after HLSL which uses this formulation
very odd choice to not be able to use the operator
I see
{
return quaternion(a.value.wwww * b.value + (a.value.xyzx * b.value.wwwx + a.value.yzxy * b.value.zxyy) * float4(1f, 1f, 1f, -1f) - a.value.zxyz * b.value.yzxz);
}```
actually to be honest fair enough
Nothing is ever as easy as it seems for quarternions
!training
lol sorry I thought there was like a 750 hour course or something i saw earlier and this was the link for it
!learn
also the commands are in #854851968446365696
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Thanks!
it's also not a single course. the learn site is a collection of many courses
Yeah I love that! 🙂
if you're new though, best to stick to the learning pathways, the unity essentials pathway goes over how to use the editor and some game dev related concepts in general, then there's the junior programmer pathway that covers how to use c# in the unity engine, and the creative core pathway that teaches concepts like lighting and shading
I'm already slightly experienced with Unity from random tutorials and stuff. I've modeled a spider asset and put it in my game and animated it and stuff. But I want to create a menu which I've never done before, and I was thinking a might be able to find something in the site
I exported my game for mac and for some reason, the camera's really zoomed in, the camera is also a square now, and all im seeing is the blue screen in the background. It works fine in game view in editor however.
It keeps on flashing between white, blue, and yellow
even if i create a completely empty scene and export only that, this keeps on happening
I have no idea what's happening
this does not seem like a code issue. but you'll probably need to provide more details about your build settings and the like in a more relevant channel
#🔎┃find-a-channel
Anyone double check this I feel like I've made some stupid logic error somewhere
Context is I'm spawning some rocks from a volcano and want them to fly through the air to a set impact point. Doing this instead of some physics thing cause the impact and spawn points being precise and easily changable is important.
[BurstCompile]
public partial struct MoveEruptionRocksJob : IJobEntity
{
[BurstCompile]
public void Execute(in EruptionRockData rockData, ref LocalTransform transform, ref PhysicsVelocity physicsVelocity)
{
quaternion directionToImpactPoint = quaternion.LookRotation(rockData.ImpactPoint - transform.Position, new float3(0f, 1f, 0f));
float angle = math.angle(transform.Rotation, directionToImpactPoint);
if (angle == 0f) transform.Rotation = directionToImpactPoint;
else transform.Rotation = math.slerp(transform.Rotation, directionToImpactPoint, math.min(1f, rockData.RotationSpeedRadians / angle));
physicsVelocity.Linear = transform.Forward() * rockData.MovementSpeed;
}
}
Blue is intended, red is what's happening
math.slerp(transform.Rotation, directionToImpactPoint, math.min(1f, rockData.RotationSpeedRadians / angle));
Looks like you're trying to do a Slerp with a quaternion and a direction vector?
Shouldn't it be two direction vectors?
Also this is a "wrong slerp"
I can't seem to find the input action. It gives me a null error.
private void Start()
{
_blockAction = InputSystem.actions.FindAction("OverheadBlock");
}
why not use serialized references?
Oh never mind it works after changing something.
Took me so long nothing worked but I did something now and it worked. Sorry
directionToImpactPoint is a quaternion
It’s set in the code I sent
What do you mean by that
oh true
Applying lerp so that it produces smooth, imperfect movement towards a target value.
I'm not 100% sure what this means but
the reason I'm using lerp here is simply because... I looked at Quaternion.RotateTowards and copied the functionality
I essentially want burstable Quaternion.RotateTowards()
but it just doesn't exist in unity.mathematics
oh you're also not normalizing your direction vector
which actually matters in unity mathematics
you need to either normalize or use LookRotationSafe
yeah that was it
like i said I thought it was just some silly error but sometimes those are so hard to spot yourself without walking away and coming back xD
but i gotta get this done today
tx
but on this
isn't this meant to be saying that value will never reach the intended value because using something like deltaTime * speed will not ever be 1
meaning you will never actually reach the full value
yes\
alright
in that case I don't think this is the same scenario because it will be 1 when the angle from current direction to intended direction is less than the rotations peed
that's why theres the math.min after all
so it doesn't overshoot
anyone know whats going on?
I thought it'd be nice to put a bunch of events in a static class called GameEvents where I can just invoke and subscribe from anywhere. then I find out you can't invoke an event from outside the class... is there a solution for this? or maybe is there a proper way of doing what I want that I don't know about?
Seems... fliped? Like what's the material? Why do you need it? How should it look?
wouldnt proceed this way myself, but the workaround would be a public static method to invoke the event from inside the class
Or if you dont really care that things could modify the delegate, you could exclude the event keyword. Since the purpose of event is to restrict access
If you REALLY need it, you can swap the events from an UnityAction, but I wouldn't reccomend passing all events from a central class, is kinda pointless
That is what the event keyword does, prevents it from being directly invoked from outside the class
yes
what you are trying to do should be done with an event channel
event channel?
its a design pattern
In this second devlog, we look at how we employed ScriptableObjects to create a flexible and powerful game architecture for "Chop Chop", the first Unity Open Project.
🔗 Get the demo used in this video on the Github branch:
https://github.com/UnityTechnologies/open-project-1/tree/devlogs/2-scriptable-objects
(compatible with Unity 2020.2b and...
this might be helpful to you
I mean of course you do not HAVE to implement this pattern
it sounds nice
but your use case seems to be 'I want to relay when many things happen to many other things'
that is the purpose of the event channel pattern
This "event channel" literally is just moving the event to a scriptable object. I really wouldnt go this route either. It's never had a proper reasoning for existing other than small scale tests pretending like its cleaner. Suddenly you have assets for every unique event that needs to exist in the game
And it really is a misuse of what scriptable objects are
I think it maybe(?) might be useful in a particular environment where your working with designers and programmers but also do not have the time/experience budget to handle that relationship via custom editors/inspectors, maybe visual scripting stuff etc. but outside from that yeah
It's not like you need custom editor functionality, and unity events already exist too. Not sure what visual scripting has to do with this
A proper implementation would be the event bus, but might be overkill here
I thought it would just be nice to have a central location that can handle events like OnTurnEnd, OnAttackSelected and OnAttackConfirmed
I have personally found the pattern very useful for mid size projects
And your static class already does this
perhaps because it simplifies things a little in a way that doesn't create dependencies in scene
Now with SO you just need to create assets on top of it for no reason
which makes multi scening waaaay waaaay easier
statics aren't scene reliant tho
with my class I can't do something like GameEvents.OnAttackSelected?.Invoke() from the UI manager. cuz of the afformentioned event keyword. do I just need to remove it then?
Adding a public function to call an event is the way to go
unwise to remove the event keyword
This has nothing to do with static. We wrote different solutions above
The SO solution would literally be the same problem because you're moving the event to the SO
keep in mind that in general it's really worth considering if your UIManager should be able to call GameEvents.OnAttackSelected directly
I do think a lot of the benefit of the event channel approach is certainly psychological
I get that so I understand that the event channel pattern might not be it. but what is xD
orrrr ease of understanding if that makes sense
As rob said, just make a public function in your game event class if you want. That function invokes the event.
just before you ever do anything like this you need to sit down and think if its actually necessary
well the UIManager might have a function that a button subscribes to, the button you click to select an attack.
but maybe an auto battle manager also wants to call that event so it can't just be in the UIManager
There was also like 3 solutions listed here
#💻┃code-beginner message
Public function, remove event, or use unityevent
that does make sense, separate function for each kinda hurts though. is there a way to make it 1 function and to pass in the event? if not I could always make an enum and use a switch case
The easiest way would be just removing the event keyword
In that case you open up the delegate to be modified, so anything could go and set the delegate to null
yea that sounds like a no-go
you can't have it protected but avoid the work of protecting it at the same time
I mean you can but that's as much work as just adding some functions
true :c
if you're looking at that solution and thinking oh my god that's gonna take hours then you need to seriously reconsider whether you need all of those events
I truthfully dont consider it an issue though yea I see why you might want to avoid that possibility. To me its on the same level of already being able to loop through the scene and delete every gameobject through any class. You just dont set the delegate to null because you are smarter than that
A public function is the common way
seems like an antipattern. That event belongs on the ui manager
and the point of a function middlemanning the process in general is that the function itself can validate that the related logic is safely in place to correctly fire that event off safely
actually if they're all separate functions I can give them separate parameters 
function is also great for debugging :)
I guess but then the auto play has to interact with the UI which also doesn't make sense
why doesn't that make sense
fake player jumping through the same hoops the player is
UI is for a player to interact with
code calling a button's on click events is just cursed xD
your UIManager is doing two jobs for you
communicating between the front end of the game and the player
communicating between the front end of the game and the back end
treating the fake player equally might work nicely
and as youve said, it's not an on click event, it's an on attack selected event
call the script that holds those attack related events attackmanager or combatmanager or something if you think it makes more sense
the UI should be calling some shared method that both it and the autoplay call.
well that's where this idea started, and turned into "I want a central hub from where common game events can be invoked and subscribed to"
you need another layer of abstraction in there
(splitting up these two jobs)

as much as you think it doesnt make sense that your auto play is interacting with ui then it would make just as little sense that the player is interacting with the combat system
player -> ui -> combat <- autoplay makes the most sense no?
yea
Using the Input System/Player Input component, how can I briefly (for the span of a Coroutine) disable only the 'Player' Action Map, but leave the 'UI' one active? I want the player to be unable to move sideways as their (2D) character is dashing, but obviously they should still be able to pause the game.
why my msg get del
!collab 👇
:loudspeaker: Collaborating and Job Posting
We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• Collaboration & Jobs
and that is why it got deleted probably
Read the warning. You were already linked that
action maps have Enable() and Disable()
How do I get the correct Action Map from the PlayerInput component? I tried looking at the API but I don't get it.
myPlayerInputComponent.actions.FindActionMap("UI") for example
to spell it out more:
InputActionAsset asset = myPlayerInput.actions;
ActionMap uiMap = asset.FindActionMap("UI");```
GetComponent<PlayerInput>().actions.FindActionMap("Player").Disable();
Would that work? Provided I'm on the same GameObject as the PlayerInput.
yes, but it's best to cache some of those intermediate things rather than fetching them fresh each time
I think the actual class is called 'InputActionMap', right? Just 'ActionMap' isn't working.
And it actually autocompletes to InputActionMap.
Good point. Got it, thanks.
Yep, it's working exactly as intended. Thanks for the help.
sorry yes, my mistake
All good. Thanks for the help^^
Halloo
I'm making a sort of vampire survivors clone, and a question crossed my mind. You see, I have an XPOrb object that is attracted to the Player object. So the xp orb will constantly get closer to the player.
My implementation for this is fairly simple:
...
float speed = 4;
GameObject player;
...
private void Update()
{
transform.position += (player.transform.position - transform.position) * speed * Time.deltaTime;
}
...
This is just some vector magic to move the orb into the player, and it works just fine. But I was wondering whether there would be better ways to do this. For example, I could have the orb sort of point towards the player, and have it move towards that direction it faces. I'm sure this would also work, but is it better in any way?
If the rotation of the orb doesn't matter then it's the same thing
Note that what you have now makes the orb move slower when it gets closer to the player
Oh yeah, I forgot to normalize it
Alrighty then, thank you
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Vector3.MoveTowards.html
there is a built in method for this.
also i assume this isnt big deal since XP orbs usually are destroyed upon reaching the player but your current method could technically overshoot. for other scenarios this might matter
Oh, I didn't know that, thanks!
how do i reference a script in the same object? im trying to get a value from another script then use that to set a playerpref
GetComponent
thank you
hello can i have some help please, my script works but theres no code highlighting, ive done everything in the tutorial to vonnect vs with unity but nothing seems to work
show what your external tools script editor setting is set to
sure
Hihi, I literally dont' know how to code and I've already ran into a problem. I am trying to trigger OnMouseDown() on an object that has a 2d Box collider and rigidbody, and I have it put something out into the log when it triggers, but when I go into play mode I cannot get the OnMouseDown() to trigger in the first place, despite clicking on said object
bro i js deleted that project opened a new one and it works now
so weird
and i even tried regenerating the files in the old one so i wouldnt have to delete and open a new one
ffs
Make sure you have an event system and a physics raycaster in the scene.
guys here rb.AddForce(0,2,100 * Time.deltaTime);
Is it onlt 100 that is getting multiplied with deltatime?
so is it the only force thats framerate independant?
I’m trying to make a time stop mechanic for my game, I’ve seen some people turning everything into rb.iskinematic and storing the velocity as a separate variable, but is there a better way of doing it?
Yes. You'd usually implement everything with that mechanic in mind, multiplying everything that could move with a time scale multiplier.
You can also try using Time.timeScale, but it's not recommended.
So lets say if timeStopTriggered = true, we assign the moveable objects a multiplier for their velocity to be 0?
Yea that makes sense
Yep
Wow didn’t expect the solution to be this simple
But then my question become like if i want to add force
How would i do that on the object
Should I apply the force afterwards?
Use like a coroutine that checks for delay for time stop and apply the attack afterwards?
Well, you could try applying the multiplier to the forces.
Or you could change the physics time step.
I’m thinking of dampening the force by timestopForceMultiplier = 0.05 on hit and then store the full force/velocity in an external variable like lastRecordedVelocity and apply the rest of the velocity
how do i unload a scene?
I ALREADY ASKED GOOGLE AND CHAT GPT AND THEY GAVE ME AN ANSWER THAT DIDNT WORK
it loads the scene but doesnt unload the past one
If ChatGPT couldn't solve it, it's not possible.
Lmfao
then specify that and what didnt work in your initial question. people dont wanna play 20 questions to figure out whats wrong.
is the scene name correct? did u verify the code is running with logs?
To my knowledge chatgpt is not using unity 6 as its basis of response because it haven’t came out yet
the scene is correct and i verified the code is running with logs. the new screen loads but doesnt unload the past one
im using the 2022 version
Considering you're not doing an additive scene load, loading a new scene would be unloading all previous scenes already
ah i was just typing that
i fixed it i just erased the unload thingy and it worked
i had an additive load scene but when the code ran it crated a shit load of scenes
making crazy lag
So you should probably make it load only one scene
yeah i did that i fixed it
yo can someone help me with some enemy ai coding
!ask
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #854851968446365696
https://paste.mod.gg/
Yo i wanted to ask yall something i made an enemy sprite with animations and a code but the problem is that my enemy is stuck at the walking animation and i already tried it with AI to fix it cuz its my first time using Unity. Is anyone avaible to help me with my problem?
A tool for sharing your source code with the world!
oops
how can i copy it correctly
nvm it works like this aswell
Not really, we can't read all that and there's no syntax
okay
Go back to this site, paste the code, press save, then copy the link
A tool for sharing your source code with the world!
There's a few animation parts in your code, none of which change the animation to walking, so that likely means none of your animations are being played in the code considering that
alr
Probably not important, but when I drag the cursor outside the game window, it stops doing stuff like moving camera down if the mouse was on the bottom part of the screen. Is there a way to get the last mouse position inside the window so it can continue dragging even if you move out of it? Should I even worry about that?
I have seen many games work like that and I kinda assumed was the default thing
I wouldn't say it's worth stressing over unless it ends up causing issues
Prob not, but I can see how that can turn extremelly annoying if playing on a window, for it is rn
but i want it to be consistent that the walking animation is consistent
My advice is: if you can't code it yourself, or at least don't understand the generated code, don't use AI for that purpose.
Maybe in a few more years it would be feasible, but not yet. You'll just get yourself in rabbit hole with a garbage of a project.
To make it clear I'm talking about a serious production aimed project. Not the sort of trash vibe coding projects that plague the internet now.
Shouldn't be the previous scene be unloaded by default if you just do a normal scene load anyways?
Like anything without DontDestroyOnLoad should just be removed automatically
If you do a normal scene load, yes.
So... why is he doing a normal load and Async Unload???
Good question. Probably because they've no clue what they're doing.
And they probably confused the llm too while messing around
Anyone can teach me how to make inventory like rust game. I already tried to use unity free asset also watching yt tutorials but it is not working.
go from what youve already got
how exactly isn't it working?
I have a question. I played my game in editor, and It didn't make any error(Also Visual Studio Code). But I can't build it because of 'Error building Player because scripts had compile errors' Why unity keeps on showing me this kind of error? Does anybody have any idea?
is there anything else in the console? it should usually show you the compile errors
Console shows me nothing...
If you have a script that is not properly closed (has wrong format) it would not compile at all and the editor would run with the unedited code you had before. Still, it will tell you yo cannot make a build with scripts with compile erros, cause you HAVE compile errors
Just that they are being checked by the IDE and not Unity
Well, what should I use for checking in Unity context? Is there any extension in VSCode for that??
as a sanity check, i would look in the log files and search for 'error'
https://docs.unity3d.com/6000.1/Documentation/Manual/log-files.html
I'll try it.
!ide has a link for configuring vscode
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
though id assume you would notice having compile errors when running the game in editor since you said you played it in editor
Should be showing erros by default tbh...
If the build fails because of compile errors, the console should show at least the error that says compilation failed. Open the console right after the compilation failed and make sure errors aren't hidden
look for your operating system then id assume this would fall under Editor
but yea also i shouldve checked first, your errors might be hidden. also the most common time we see people struggle with that error is when they use UnityEditor and try to include that in a build
can you send a screenshot of the console?
I'm not sure this would be helpful...
ChatGPT also told me about if endif, but not in my case.
just using UnityEngine;
chatgpt is as good as asking a random guy on the street. id look into your editor logs then
maybe some class you forgot about is using UnityEditor
You mean I should or I shouldn't?
[main 2025-05-19T06:43:08.544Z] update#setState checking for updates
[main 2025-05-19T06:43:08.674Z] update#setState idle
is this what you want...?
check your editor logs and search for any errors. not sure why there isnt more info in console. is there maybe more info if you click the errors themselves? havent actually had this issue in awhile so i dont remember whats supposed to show
your log files should have way more than just that
oh I found more up there
I'll try ctrl F and search for error
Build completed with a result of 'Failed' in 8 seconds (8157 ms)
Error building Player because scripts had compiler errors
UnityEngine.Debug:ExtractStackTraceNoAlloc (byte*,int,string)
UnityEngine.StackTraceUtility:ExtractStackTrace ()
UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:LogError (object)
UnityEditor.BuildPlayerWindow/DefaultBuildMethods:BuildPlayer (UnityEditor.BuildPlayerOptions)
UnityEditor.BuildPlayerWindow:CallBuildMethods (bool,UnityEditor.BuildOptions)
UnityEditor.Build.Profile.BuildProfileModuleUtil:CallInternalBuildMethods (bool,UnityEditor.BuildOptions)
UnityEditor.Build.Profile.BuildProfileWindow/<>c__DisplayClass44_0:<OnBuildButtonClicked>b__0 ()
UnityEditor.EditorApplication:Internal_CallDelayFunctions ()
I guess this is the most recent error log. I have something more down here, but I think it doesn't have a direct relation to this.
Can you figure out the problem???
That error is quite useless in terms of figuring it out
Oh...
Just tells us the build failed, other errors will say why
that one does indeed just saying it started to build then there is like 6 lines just relating to a logging statement
By any chance, do you have this in your code?
yes
Then you need to wrap it in #if
reread the line, its engine, not editor
Oops
do you have any using UnityEditor; or #if UNITY_EDITOR?
Yeah I heard about chatGPT, but there's no using UnityEditor; in mine
just disregard whatever chatgpt told you
If you need, I will get my code capture
what about the second one? or any #if in general?
please don't screenshot code
copy and paste?
right now you have the tools to search through your project, better than we do
your ide has a "find in project" feature
is there nothing else in the log files though?
search for UnityEditor or #if in /Assets
yes, but it's quite long. wait a second.
do you have anything that starts with #? ie #if, #endif, #ifn kinda stuff
ok
Does #ifn do if not?
fixed4 PixShader(pixel_t input) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input);
float c = tex2D(_MainTex, input.atlas).a;
#ifndef UNDERLAY_ON
clip(c - input.param.x);
#endif
float scale = input.param.y;
float bias = input.param.z;
float weight = input.param.w;
float sd = (bias - c) * scale;
this?
Code samples won't help
Sorry, I'm a total noob for this...
Sometimes they do, but is there any more?
i have no clue about shader code honestly but if thats not your code then its likely not the issue. Hopefully
Id really just dig through the logs instead
if you have 3rd party assets they might use #if and other conditionals, you can ignore those
unless they were made poorly
Do you need a log that starts with
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/2 POST http://ilpp/UnityILPP.PostProcessing/Ping application/grpc -
?
This is quite long
Build Finished, Result: Failure.
##utp:{"type":"PlayerBuildInfo","version":2,"phase":"Immediate","time":1747638607497,"processId":19948,"steps":[{"description":"Preprocess Player","duration":187},{"description":"Prepare For Build","duration":10},{"description":"ProducePlayerScriptAssemblies","duration":7663}],"duration":7860}
Unloading 1 Unused Serialized files (Serialized files now loaded: 0)
Loaded scene 'Temp/__Backupscenes/0.backup'
Deserialize: 4.634 ms
Integration: 362.566 ms
Integration of assets: 0.003 ms
Thread Wait Time: 0.035 ms
Total Operation Time: 367.237 ms
Unloading 1 unused Assets / (361.8 KB). Loaded Objects now: 8972.
Memory consumption went from 366.1 MB to 365.7 MB.
Total: 28.441400 ms (FindLiveObjects: 0.636400 ms CreateObjectMapping: 0.291900 ms MarkObjects: 27.336900 ms DeleteObjects: 0.174300 ms)
or this
probably not. i would assume that it specifically says error somewhere
do you have a lot of code in this project, or by chance are you trying to build like one file. I can make a compile error and test what output i get
just three scripts in this. because I'm learning and testing.
honestly it might just be easier if you send the scripts then. !code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
but lets maybe make a thread for this
yea just send the code in there
im wondering if there is a setting i missed to make rider properly show XML documentation on mouse hover
(only broken for unity types, i guess its because we only have source "cache")
I have a variable that controls the gamestate (simple boolean) and I want it to be accessed by all objects (non-player), would it be good to declare a global variable or something else
I know that global variables are a bit weird to use and implement
Also impossible in C#
You can declare any field static and access it anywhere through the class
What you're trying to do is usually solved with singletons
It works fine here, so I'm not sure what you're missing. Perhaps the csproj files need to be generated in the External Tools settings in Unity?
thanks, this fixed it
You can use a ScriptableObject for that, its better than creating a singleton or a global variable imo
so just make a new script at this point
and call that script when i need that component
why
I would do something like this
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "Game", menuName = "Gamestate")]
public class Gamestate: ScriptableObject
{
public bool gameState;
}
and then in your other scripts create a public variable called Gamestate currentGameste
And assign the ScriptableObject there
but be careful with SOs, they don't get reset when you exit playmode, so you need to add a simple logic at its enable to reset itself
respectfully this just seems like using SO's incorrectly for no apparent benefit?
Can you elaborate why you think that? I'm using Scriptable Object variables for a while and they seem to be working great
ofcourse there are other ways to handle the problem above
As you mentioned your not meant to handle runtime values in SO's like that. I don't know what benefit chucking it in a reference based scriptableobject is providing rather than just singletons or statics
you could just use gameobjects and not have to be careful about all the potential side effects of SOs
You can handle runtime values in SO by making an OnEnable checker, its very easy to add + I don't like Singletons because they don't allow you test independent logic if thats not present in the scene (which in many cases it won't be)
as I said, you can use a singleton for the problem mentioned above, but in my opinion a SO variable is better
I would need to actively update this function in runtime and would be the only instance in my game so I am leaning towards using a singleton rn
I can see the SO being a solution but im not sure about the downsides
go ahead and use a singleton then its not bad! every "pattern" has its downside/upsides ofc
quick question
It's better to make an external script for this singleton class right? Do I script the singleton as a boolean only or is it better to make the entire behavior within the class?
Yeah make a different script called GameState where this will be a singleton, and call it from any other script you want using GameState.Instance
Its better to not combine classes to be easier to debug later on
I would just have a gamemanager class that holds the bool and have it either be a singleton or just static
It'll look likeif (GameState.Instance.Boolean)
whenever I call the singleton
just initalize the class as a singleton essentially right?
yeah, make a boolean called currentGameState instead of Boolean (just for better readibility)
Why SO over just statics then?
yea im just too lazy to think of an actual variable rn
SO have many advantages imo, Inspector visibility, edit them in runtime(for testing), decouple as you don't have to connect your script to another script
inspector visualisation is fair. not sure how SO's would be more coupled in this context?
SOs are assets, not scripts, so you don't have to reference ScriptA from ScriptB (like you would if you create a GameManager class with a static)
but yeah, I love inspector visibility, I think its a great feature to use
how are you using the SO in any meaningful way without referencing the variable inside of it via code?
you are referencing the SO, you make a variable of that SO in the scriptA, you just don't have to access a script (as that script may not exist in the scene)
script != monobehaviour
so's are scripts just as much as monobehaviours are
MySOGameStateRef myRef
void Function()
if (myRef.gamestatevalue)
void Function()
if (MyStaticGameStateClass.gamestatevalue)
your still gonna be referencing the value of another script via code regardless
What I'm saying is that the SO doesn't live in the scene, so you can access it from anywhere by assign it in the inspector, you don't have to have a script attached to a gameobject to get that value, which makes it great for testing in test scenes
sure but i was asking why not use static values
if its just the inspector thing thats fine i was just confused
with static variables you create a dependency on the script itself with the static variable, while with SO Variable you are referencing the data itself
public void OnDrag(PointerEventData eventData)
{
Debug.Log("Dragging");
Vector3 screenPoint = new Vector3(eventData.position.x, eventData.position.y, Camera.main.WorldToScreenPoint(transform.position).z);
transform.position = Camera.main.ScreenToWorldPoint(screenPoint);
}``` I want to drag the object but not the object's child.
..via the script
sos are scripts
I think we are going in circles, lets leave it at singletons/statics have their uses, and SOs have their own
i don't know if you are using the term script accurately
Static values are not tied to any specific instance. They don't get reset when something is destroyed and recreated, once set, they remain in memory for the entire duration of the program, they're shared between all objects everywhere.
In general, it's better to have a static reference to an instance of a class (usually Singletons) than a static field, because that gives you freedom to dispose of a variable when it's not needed, reset it, serialize it to disk, view it in the inspector, etc.
A child object will maintain its position relative to its parent as the parent moves. If you want to leave this child object behind during this you will need to un-parent the object, move the parent, then re-parent it
Can anyone help me? no mater the project or version I get a grey screen,I can only see gizmos, on the scene editor and the game view. I tried deleting my ~/.config/unity3d folder, and reinstalling unity, but nothing seems to work.
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
ty unity dyno bot
https://hastebin.com/share/levazodisu.csharp
if anyone could take a look, i have a problem with this script.
i was basically trying to have it so that when they crouch (that method is at the bottom of the script) they would slow down.
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
i had reasoned that multiplying it by something less than 1 would make the movement speed smaller, but it basically had 0 effect. it wasnt until i started putting negative numbers, that it started slowing down
as long as the negative number did not have an absolute value greater than the walk speed, it would slow down
if it did have a greater value, then i'd just start having reversed controls
Hi, i have a custom package on github also it's depended to another package which is on github. When i tried to install my custom package it couldn't find it's dependency. What should i do?
i am getting this error : Expected a 'SemVer' compatible value.
Example package.json
{
"name": "com.yourname.mypackage",
"version": "1.0.0",
"displayName": "My Custom Package",
"description": "A description of your package.",
"unity": "2021.3",
"dependencies": {
"com.other.dependency": "https://github.com/username/other-unity-package.git#1.0.0"
}
}
does anyone know which part is the faulty bit?
this kind of dependency is not supported which is why it was not added automatically
What should i do?
you would need to host the packages customly to support dependencies (git packages cannot depend on git packages): https://docs.unity3d.com/Manual/upm-scoped-host.html
openupm exists but ofc those are all public
i can install my base package to unity but i can't other one which is depended to base. Still doesn't get it what to do
https://openupm.com/packages/com.dbrizov.naughtyattributes/#modal-manualinstallation the way I've always installed packages is the method that UPM explains with the manual installation steps
I imagine if you copy these same steps, but substitute the UPM registry lines with your own, that should install just the same
all its doing is telling the package manager what address to look in
If you're using a CharacterController, you shouldn't be calling .Move more than once per frame. You should build up a vector over the course of Update that you then pass to Move all at once. Right now each Move resolves individually, changing one doesn't affect the others.
Is there any way someone can fix my script so that space bar allows my player to jump? I cannot get it to work, but i have the rest of it finished
I can send it to whoever is able to fix it
best chance youve got is to post the code in the first place
Trying to make a mechanic where the player can bust through breakable objects via tags. Right now the collision Hanlder script works just fine, but I wanted the object to shatter and break when collided with. I made a separate break script but the issue is that the breakable rock in this case is shattering when I load into the level when it should only do that when colliding. I've so far tried to call it when it only collides with the player(has a "Player" tag), but the issue persists. Gravity is turned off for the yellow rock(Breakable object in question).
Debug.Log to see what it's colliding with when it prematurely shatters
i use SOs for everything that is static data
super useful
easy to access and non-programmers can easily edit the data too
so I am experiencing a really weird issue
if (other.gameObject.CompareTag("Wall")) //if it's a wall, bounce off
{
rb.velocity = Vector3.Reflect(currentVelocity, other.GetContact(0).normal);
transform.rotation = Quaternion.LookRotation(rb.velocity.normalized);
rb.angularVelocity = Vector3.zero;
if (bounces > 0)
{
bounces--;
AudioHandler.Instance.PlaySound("Bounce");
if (bounceParticle != null)
{
ParticleSystem bounce = Instantiate(bounceParticle);
bounce.transform.position = bounceParticle.transform.position;
bounce.gameObject.SetActive(true);
bounce.transform.parent = null;
Destroy(bounce, 1);
}
}
else if (gameObject.activeSelf)
{
DestroyDusts();
if(pool != null)
pool.Release(gameObject);
}
}```
i have these lines for making a projectile bounce off of a wall, if it has a bounce left
problem is for some reason, in one scene, it works, and in the other one, it doesnt
all the variables are the same
What debugging steps have you taken?
I use a single prefab over all scenes
I've been getting an info thing with the lookrotation being zero for the transform.rotation
so I tried looking at the rb.velocity before and after the reflect
nothing wrong with it
well that seems like a pretty clear indication that rb.velocity is 0
except that it isnt somehow
Add Debug.Logs to your code
because it is moving
wtf
sometimes it is, sometimes it isnt
but theres no visual indicator
maybe the issue is that it collides with the wall, and so the velocity becomes 0?
sometimes it just does the check late?
When something works in one scene but not in another it often means there's a separate or duplicate script/object that is influencing it
it always does the check late. OnCollisionEnter happens after the collision. If you want an accurate bounce without losing speed the best thing to do is either:
- record your "lastVelocity" in FixedUpdate and use that along with the hit point and normal to reflect it in OCE.
- use the information from the collision including
relativeVelocityalong with the hit point and normal to accuirately reflect the velocity.
I also recommend against modifyinbg the Transform directly like you are doing with transform.rotation here
what's a better alternative?
rotate the Rigidbody
also fuck I just ran the game without rebaking the fucking navmeshes
why tf does it cause a memory leak
fuuck
so annoying
what's the difference, if I may ask?
settting the transform directly doesn't use physics engine and you're basically teleporting
by rotating the rigidbody w/ a rigidbody function it does
You should basically never touch the Transform when using physics.
It breaks interpolation
It can teleport objects inside each other and leave the physices engine to suddenly and violently deconflict them
it generally leads to unpleasantness for the user
I'm trying to make a dash sound effect when a dash ability is being performed. Audio clip by itself works fine but it isn't playing when the dash is being performed:
{
if (canDash && !isDashing)
{
StartCoroutine(PerformDash());
}
}
private System.Collections.IEnumerator PerformDash()
{
canDash = false;
isDashing = true;
audioSource.PlayOneShot(DashSFX);
Vector3 dashForce = transform.right * (dashDistance / dashDuration);
rb.AddForce(dashForce, ForceMode.VelocityChange)
yield return new WaitForSeconds(dashDuration);
isDashing = false;
// Start cooldown
yield return new WaitForSeconds(dashCooldown);
canDash = true;
}```
Code looks ok. Is everything assigned how you expect? Volume on audio source is > 0, etc?
If you move the audioSource line up into the beginning of the Dash() method before the if statement does it work? Just might try moving it there to make it easier to debug. It shouldn't matter that it's in a coroutine.
Yes the volume is > 0. I tested it with using it alongside another audio source not too long ago to see if the audio's volume was even hearable. It was
Moving it at the beginning of public void Dash() didn't work
You should try set
isDashing = true;```
before starting the coroutine.
It waits one frame to activate, so maybe you start more than one. I think.
Is the audio source being used for other things? PlayOneShot won't stop anything that's already playing.
When you do StartCoroutine, it doesn't run before the next frame, it is added to a list of things to run the following frame... But not sure if that is the issue.
I think its depends on how you start it actually
It should do everything up until the first yield statement right away
the audio clip itself is being used once aka the dash. It isn't meant to override any other audio playing and is meant to be used in tandom since its a lot shorter compared to the other audio clips being played. I do have some SerializeFields of audio clips which this one is [SerializeField] AudioClip DashSFX; , which utilizes AudioSource audioSource. The DashSFX sound itself is currently selected in the editor
All the other audio clips work fine except for that one
Hmmm... well, if you're only using that audio source for this one clip, that's probably fine. No errors or anything, you just can't hear it?
Want to show your audio source settings? Only other place I can think of it might have gotten messed up on accident.
Also for reference audioSource is referenced multiple times in this script, so if that's what you're referring to as it being used for other things, then yes it is
Try just stopping it before playing to test that issue. audioSource.Stop();
For example, I use audioSource again when making mainEngineSFX(the sound that plays when the player moves) via if (!audioSource.isPlaying) { audioSource.PlayOneShot(mainEngineSFX); }
Ok, I'll try that and see what happens
You are right, I just tested it in Unity 2018 and get the same result as on newer Unity. Don't know why I had this idea.
So I'm having a curious issue if anyone can help, the issue is that in a 3D game my player gets stuck in the air when jumping at a wall before slowly coming back down. I'm using transform for sideways and forward movement but the jump is done through a rigidbody, I know I can fix this by using a physics material and turning Dynamic Friction to 0 but then I just slide off any hills in the game. Thank you for any help :)
guys what do i do about this if (MusicSource != null && EnemyDealDamageToBase != null)
{
Debug.Log("Audio is going to play!");
MusicSource.clip = EnemyDealDamageToBase;
MusicSource.Play();
}
im getting the debug log that the audio is going to play
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
but i dont hear it
are you playing it every frame? Every time you call Play the clip restarts
in the update()?
its not in update
where is it?
private void DealDamageToBase()
{
if (levelManager != null)
{
levelManager.Lives -= damageToBase;
}
if (MusicSource != null && EnemyDealDamageToBase != null)
{
Debug.Log("Audio is going to play!");
MusicSource.clip = EnemyDealDamageToBase;
MusicSource.Play();
}
}
So perhaps you should post the full code so there's context as to what is calling it
Please share your code as per the bot's instructions
And this doesn't tell us anything
we have no idea where this method is running from
A tool for sharing your source code with the world!
DealDamageToBase();
EnemySpawner.onEnemyDestroy?.Invoke();
Destroy(gameObject);```
looks to me like you're destroying your audio source immediately after calling Play
A destroyed object won't be making much noise
or none?
so i just have to delay the destroygameobject and then it will play?
Im very new and sorry if I shouldn't ask this here but can someone please tell me if their is a way to resolve this so I can work on my game
Open the log folder and see if there's anything in there that says "Error" or something similar
Probably near the end of the log file
I see these at the end of the info-log, is this what you mean?
Yes, you could add a property "timeUntilDestroy = 3f;" and in Update() do like ```cs
if (timeUntilDestroy > 0) {
timeUntilDestroy -= Time.deltatime;
if (timeUntilDestroy <= 0) {
gameObject.SetActive(false);
}
}
read the whole message
do i put that in my game
their is a LOT of stuff and after looking for things with "error" in them in nailed it down to 252
I just mean the whole message on either of those last two lines
ideally both
it would seem I don't have the file on my pc even tho I thought I used uniny cloud to send it from the school pc to my home pc
which file
well its not just 1 file but the whole thing isn't on my pc
wdym by "the whole thing"?
Maybe sharing the full error message here would be helpful
Can you show this folder in windows explorer?
C:\Users\trevo\Violet Rot\Violet Rot
(is the last part intentionally duplicated?)
no its not I didn't mean to do that
so it looks like you probably just gave the wrong filepath to the hub
how would I go about fixing that?
Excuse me, I need help. I made a webgl game, in said game I put 2 UI panels with messages. Both work on editor. But, when I build the game and play on itch io, the second panel wont show up, in fact, the game goes on as it was there (when a message spawns, the CC stops until its closed).
most likely it's just not visible on the screen due to the different resolution / aspect ratio
Which means you didn't anchor your UI properly
but its the same res and config as the first panel
I fixed this by attaching the frictionless material to the walls
Test it in the editor game view with the same resolution you had in the web view
You can set the editor game view resolution freely
okay
its not in my disk I went through my veaditube folder
well if the project isn't on your computer, that would explain why it can't be opened.
I have the game and all the branches on my unity acc but just not on my pc is their way for me just to download those onto my pc
of course:
works fine in every res
same problem happens, it just tells me it could not be opened and to please check my logs
ok and what do the logs say this time?
ok just to check these are the only ones that should be here right?
yes
alr cool
by the way you never really showed it but - does the C:\\Users\\trevo\\Violet Rot folder exist at all?
hey i was wondering how to fix this issue. In the events tab, i cant seem to find any functions although the code matches everything within the tutorial im following.
nope....
SOunds like you have your location set wrong for project creation then
I gotta download all the stuff from my unity acc and make a copy of it
in the hub you need to click the Gear Icon - Go to the Projects tab - and make sure the project location default is set to a folder that actually exists
looks to me like you dragged the wrong thing into the slot
you dragged the script itself in
you need to drag the object that has the script on it
Did you drag in an object with that component on it or the text file containing the code
SOunds like a bad tutorial
lmaoo
Can it be that an OnPointerUp and a OnPointerExit trigger on the same exact frame on the same button???
I am playing a sound when the pointer is Up and he cursor was over the image, but sometimes, and just sometimes, if you are fast enough, you can make the sound play without pressing the button
Hello, I'm trying to have one Monobehavior script handle keyboard input, where each keypress check in update will just invoke an event (is this the correct term?). Is this a bad way? Or should I just put the keyboard i/o in the class where the inputs are actually used
It can be useful under certain circumstances, for example if you want to be able to swap out behavior in the inspector with a UnityEvent
Is there a specific reason or use case that you want to do this for?
i was adding an inventory and ui that can be toggled by the keyboard
no specific use case
I would avoid adding complexity to the code for no tangible benefit
oh i didn't know it was more complexity
if there's some benefit like you want to have inspector-swappable behavior or something else, then go for it
for me it was easier to think about with using events
YOu could switch to the new input system
which supports event-based input handling out of the box
oh cool I'll take a look
it has a learning curve, fair warning 😉
Hi, I am loading scenes additively and asynchronously, but I need to do a transform on the root game objects before the first physics frame, relative to the position and rotation of the scene (technically the root game object of the scene) that triggered it. In the loading scene's awake function, I get the triggering scene's root game objects, then have to load a script, then read the list describing the relative neighboring scenes.
I was wondering if there was an easier way. I'd like to have it the triggering scene do the transform before the scene loads in the first frame but with async and waiting I feel like that is a bit finicky.
You could have a script in the loaded scene invoke a static event that some other script in the existing scene is listening to, passing itself as a parameter. THen that listener script can do the thing
Hello!
I'm banging my head against the wall and desperately need someone to help me 🥹
I'm trying to create an object that creates the battle backgrounds for my game (it's for a 2D side-view battle type RPG).
- The way it works is that I have an object on scene called "Battleback", and a prefab called "BattlebackLayer".
- The prefab has a Sprite Renderer component, but no sprite assigned to it.
- Once the game starts, I initialize several Background compositions on BattlebackLibrary
- After Initialization, Instantiate BattlebackLayer objects on a for loop. Assign sprite, change name and sorting order.
Result: Everything works fine, except for the Sprites, which are never loaded. I have no idea why, can anyone give me a pointer on what I'm doin wrong?
A tool for sharing your source code with the world!
What do you mean by "the sprites are never loaded"?
they are null?
If Resources.Load is returning null, then you didn't put them in the right place in ytour project for use with Resources.
The requirements for that are spelled out in the docs - have you read it? https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Resources.Load.html
Anyway - to be honest this seems like a misuse of Resources.Load. Since you're essentially just hardcoding these paths - it would probably be better to just populate the sprite references in the inspector
Then you don't have to go and change the code whenever you want to add/change/remove any of these things.
I'm looking into it to see if I missed something
I mean based on your comments and original ddescription I would guess you didn't actually put them in a resources folder
Hmm, that wouldn't allow me to do what I want. Since I want to change the backgrounds dynamically, not on the editor directly
What do you mean? There's nothing dynamic in this script
it's all hardcoded
Weird, I don't even have a resources folder. I'll add it in and test it out. Thanks!
The only hardcoded thing I have is presets
which are initialized at the start
other than that, it's supposed to be dynamic
You shouldn't create a Resources folder unless you actually need it, it just makes it more complex for no real reason
Just assign the sprites you want to use to a list manually
Yeah but there's no benefit you're getting here from Resources
because you're just hardcoding the paths
you might as well assign the sprites in the inspector
YOu can do this for example:
@fringe moat
A tool for sharing your source code with the world!
Well, this is just the first version of the script haha, I haven't even gotten it this to work, I can only start thinking about scaling after I get this working at least
I'm still finding my way around Unity, I don't quite know how resource management works yet.
So you suggest I load all of the battleback sprites into the battleback object, and from there apply them to each individual BattleLayer object?
That way I don't need to load from resources?
Rule of thumb, if you can avoid calling something for a folder path, you do that, 100% of the time
Just to make sure I understand, in the loading scene I can have a "transform request" delegate/static event that passes the loading scene as an argument. Then the triggering scene will respond by doing the transform?
not sure what you mean by "loading scene" and "triggering scene", but the event would be a static event, not "in a scene"
it would be like:
public class Level : MonoBehaviour {
public static Action<Level> OnLevelLoaded;
void OnEnable() {
OnLevelLoaded?.Invoke(this);
}
}
public class WorldManager : MonoBehaviour {
void Awake() {
Level.OnLevelLoaded += HandleNewLevel;
}
void HandleNewLevel(Level level) {
level.transform.position = whatever;
}
}```
quick and dirty example
I think I got it, thanks again
Why's my brand new Unity 6 project stuck at 60fps in the editor playtest
Even if that's meant to be vysnc I have a 144 Hz monitor
Use the profiler to see what's limiting it
Well, it doesn't really matter how old the project is, the profiler will still tell you what's going on
select a frame
Its probably some bs like Armoury crate or Gsync on my laptop
yup
armoury crate silent mode
Went with a similar solution. I'm loading all of the available background sprites into an array, and using a struct I'm setting which I want to use. By changing the struct and calling an update function, I can get it working pretty well.
Thanks for the help!
How do you usually handle the gap when scrolling a background-type object?
This method usually works for me on other engines, but it's producing a small gap in Unity. Anyone have any tips?
` foreach (var layerGameObject in createdLayers)
{
var layerVars = layerGameObject.GetComponentInChildren<BattlebackLayerVariables>();
if (layerVars != null)
{
Vector3 pos = layerGameObject.transform.localPosition;
if (layerVars.xSpeed > 0 && pos.x > layerVars.width * 1.9f) { pos.x -= layerVars.width * 3f; }
else if (layerVars.xSpeed < 0 && pos.x < (layerVars.width * 1.9f) * -1) { pos.x += layerVars.width * 3f; }
else { pos.x += layerVars.xSpeed * Time.deltaTime; }
pos.y += layerVars.ySpeed * Time.deltaTime; // incomplete
layerGameObject.transform.localPosition = pos;
}`
Are you using Pixel Perfect camera?
Yeah! Is it causing it?
no it should be fixing it
I thought turning on Pixel snapping could fix it, but no luck either.
I got it!
I moved this: pos.x += layerVars.xSpeed * Time.deltaTime; outside of the else statement—I guess, because it was part of the conditional structure, the movement skipped a frame whenever the object was repositioned, causing it to stay one pixel behind.
hello im learning unity 6.1 and im having trouble making a rocket prefab move across the map, could anyone kindly tell me what im doing wrong? im following the tutorial and it doesnt seem to be working
its spawning but standing still
Use Debug.Log to see if your code is even running
also make sure there are no errors in the console when running as well
Actually
there's no way you followed the tutorial properly here
you are getting the Rigidbody from the prefab
instead of from the newly instantiated rocket
so you're basically trying to add a force to a prefab that lives in your project folder instead of the actual rocket you created in the scene
much appreciated
under what case do you use singletons over events
They solve entirely different things, there is no using one over the other
I'm trying to implement a pseudo-global variable to see if timestop was triggered (which effects everyone excepts the player)
I think both methods work in this case with different implantation (singleton to dictate when timestop is triggered and handle the event universally vs events which allows me to listen to the event when it happens and control the behavior directly)
I'm thinking which one i should pick over the other
This still isnt a case of choosing singleton vs events.
Let's say you go with a singleton here. The only thing this does is give you a static reference to an instance of an object. How do you now notify everything that "timestop was triggered"
Now compare this to if you wanted to only use events. An event notifies all subscribers that something happens. But where does this event live? Like what class is it in, what instance is it in?
You could use BOTH a singleton and event here
I would think pausing the update would suffice already
or w/e loop you're doing it in
I'm thinking of storing the velocity and releasing it if any moveable object was paused within the period
so simply pausing update wouldn't suffice
which means the object itself need to know when timestop was triggered by the player
some custom physics? Your velocity shouldn't just disappear if you pause the loop
so pausing update wouldn't effect the physics if the object is kinematic?
I'm a bit confused
You definitely shouldn't be doing this. Also have you tried just setting the timeScale to 0? Put a cube in your scene with a rigidbody and test it
If we're talking rigidbodies I'm pretty sure screwing with even the timescale shouldn't result in wrong velocities
the player is kinematic, I haven't exactly decided on the other objects (like enemies) but I wanted to have the ability to apply knockback by the player attacking within timestop, and modifying the original velocity when the knockback is applied
Storing the velocity is pointless because when the timeScale is 0, their movement per update or fixed update should eventually be multiplied by 0 and thus not move
Even if it's a custom timescale, your objects should all be accounting for this scale in their movements at all times
so essentially when I trigger in my controller script when key down, I set the time scale to 0 to make the same effect
my player should still be able to move even in timescale 0, because it's kinematic correct?
You should really try it and see how it works when timescale is 0. If anything is moving, that's because you arent accounting for delta time at all
Kinematic objects dont move by themselves, you must have some code moving it
i get that part, I'm more or less confused as to how timescale 0 will affect kinematic objects
because my character is kinematic
though if you do wanna have some deterministic rigidbodies then storing it all is ideal
then you can do like rewind stuff for funnsies
yea thats the idea, ragdolls and more time manipulation funnies
Hey, how do I know where this error is triggering from?
Storing it when the game ie paused should affect literally nothing
I get these errors the moment I run the game. They don't break anything, but I want to get rid of it 
I mean just storing the rigidbody state in general, not so much just pausing
The message you're replying to pretty much is saying what you should do. And that is test it out and see.
object not initialized? There's no instance of an object, check your code
ah ok
Is this related to instantiating or?
Your error is under the UnityEditor code so unless you wrote editor code, it's not your code that's the issue. Though i dont specifically know what you can do to fix that
yea
Hmm, I see
my understanding is that you have some class or object reference not called
I didn't write any editor-related code
I see
I tried debugging, as the codes are quite simple. And saw no null references anywhere
Maybe I will restart the editor
like this
Ohh, I see. Will keep that in mind!
you'll have to initialize your scripts if you call them
It was editor issue, I closed and re-opened the project, it stopped showing up
weird
Yeah
game is running fine?
Yes it is
Yeah XD
As I wrote above, yes it's not an issue with your code
Yessir, thank you!
Usually when you see strange editor errors, close and reopening should fix it. Or in the odd case it says something about nodes/graph then resetting layout might work too
I see, will keep that in mind
If it persists after closing then you have a real issue on your hands
how is ticking managed by the engine ?
since Update (and so on) arent virtuals, i imagine the engine gets them using reflection
im asking this because i have a high amount of objects running stuff on tick and i am wondering if i can save a bit of frame time if i have 1 manager ticking for all those entities
so in simpler words: what is the ticking overhead
Unity does use a form of reflection and tells every component it found to tick
If you instead have a single Update method which informs your components to tick, it makes quite a big deal in performance compared to having Unity call all of them
However, consider doing this only if it makes sense complexity wise. If you can have a parent tick its children it makes a lot mroe sense than having a base component that informs veeryhting in your application. It's unlikely that works better anyway.
thanks for the insights, since its a manager it makes sense for me to have it managing ticking its entities
sorry for the ping, i just got back
I tried it, and the kinematic objects cannot move at all, seems like it pauses everything
Is it possible to unpause only the player?
monobehaviour events are called directly from engine native code. Its able to interface with the CLR
