#💻┃code-beginner
1 messages · Page 791 of 1
i fixed it, i was calling play in update so it was executing every frame
also im using an audio mixer as well so as far as i know you cant assign multiple groupsto one audio source
tip: if you added a debug log or similar here #💻┃code-beginner message you wouldve seen that 
hello 👋 I have got a question how could i make a similar character like a xenomorph in a game called Broforce. I was just wondering how can it crawl on a wall and ceilings?
could someone please explain?
That's very vague
so i was thinking about instead of using gravity in rigidbody i could change linearvelocity
I was thinking about overriding linearVelocity instead of using Rigidbody gravity to get more control. Or is there a better/standard way to handle wall/ceiling crawling in Broforce?😭
Gravity is just some force thats always applied so you can disable gravity for a RB and apply your own force
may i ask you how?
rigidbodies have an option for using gravity. You can then just apply your own force in the direction you want each Fixed Update.
Gravity on earth is -9.18 meters a second and is what unity has configured by default too.
If you know the normal of a surface you know the direction to apply force (the opposite)
To allow movement it will require extra steps to correctly do this for the new "plane" however
You can also choose to disable gravity and just let the user move on that plane only to better control the results
https://pastebin.com/vCd1UA3r
https://pastebin.com/mjqBWbAt
https://pastebin.com/tvnyMxU9
whenever i switch to another slot the visible selection doesnt dynamically change, does anyone know why?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
can I actually just swap the OnMouseEnter & OnMouseOver functions with their pointer counterparts or do I actually have to do smth else too?
sry for the late message btw
you just have to use a pyhsics raycaster and implement the Interfaces of desire
wdym?
in your script you implement the interfaces ipointer you like
for example if you wanted the clickhandler
in your case it would be IPointerEnterHandler
U simply inherit the interface and implement its callbacks
in the docs i sent you can see all the interfaces you want to use (on ther left)
is there no OnMouseOver function for the ipointer?
OnMouseOver would be IPointerEnterHandler
YourScript : MonoBehaviour , IPointerEnterHandler
Wrong order
it starts off correct selecting the initial slot but when changing slots nothing happens and the first slot stays highlighted
even if its no longer selected
so would smth like this work? https://paste.mod.gg/fqgrayuxoqxb/0
A tool for sharing your source code with the world!
you did not implement the callback correctly
public void OnPointerEnter(PointerEventData pointerEventData)
{
your code here
}
Yes you can replace them. An event system must be in the scene and a physics raycaster /physics 2d raycaster must be added to your camera too
Implement the interface for each event you want and use the function for each interface
It shouldn't be possible to do this wrong because you are forced to implement the functions
and VS does the job actually
if you click on the small arrow when it misses the callback
Whatever ide you use will and it will cause a compile error too
true
Is there a reason why Unity VSCode sometimes randomly adds in imports I'm not using, and also is there a way to stop that because it's annoying
Unity VSCode ?
normally if you click the class in intellisense thats when namespace gets added
You probably auto completed some type so the using statement was added for you
never had vsc add namespaces on its own
wat is the equivelant to OnMouseOver for this btw?
OnPointerEnter/OnPointerExit
what kind does it add?
ya but doesn't that only register the first and last frame the mouse is hovering over smth?
there is no "OnHover" type thing
Well the most recent one I had to remove rn cuz it stopped a build was like "using Unity.PackageManager"
you use those and create your own
Which I'm not making anything to use this
and I scrolled up and it's grayed out so I know I wasn't using it
ohh yeah alright makes sense
thanks king
Pointer enter and pointer exit need to be used. If you want to do things while the pointer is over the object you need to track the state and use Update/FixedUpdate @balmy vortex
And other times it'll be random
ya I got it dw

it should highlight all the namespaces you are using and darken out the ones you are not using ion your code. at the end when you are done with the game simply remove all of those dark ones
Yeah I've just been removing them, I'll just do it at the very end or whenever it gives me build issues
sound like a nice plan
its probably tucked somewhere in the preferences in c#
I need help fixing this issue. I have this head bobbing script https://paste.ofcode.org/epEdxGCxPCSRYbP4K7YknP it works but when it rotates up and down and I look in a different direction it looks weird its suppose to look the same.
let us know if the accuracy is better than OnMouseOver as you had this morning
you should probably seperate the bobbing and the mouse rotation object
are you sure you want that effect while idle
first time i see that in a game
https://pastebin.com/vCd1UA3r
https://pastebin.com/mjqBWbAt
https://pastebin.com/tvnyMxU9
whenever i start the game it starts off correct selecting the initial slot but when changing slots nothing happens and the first slot stays highlighted
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
does anyone know what im doing wrong
I don't' have a mouse look script I am using cinemachine to look around.
Yes, it gives a natural breathing effect I might need to adjust the value a bit.
I was talking about seperating the gameobjects
yeah rotating the root for look and headbob for the effect but I never used Pan Tilt for this so I have no idea
I just use the built in Cinemachine noise and create sways there
Im not rotating the root, the tracking target is the target for cinemachine and the headbob script is in headbob and the tracking target is a child of headbob so the effect can work. If I separate them all the main issue is still there
What is a good way to learn unity? Does anyone recommend any tutorials? ( I know coding and making games, I'm just new to unity), I'm looking for somethign that won't take long but will say everything that I need, and I won't be just copying the code but actually practicing
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
you don’t have to do all of it
Hey!
Could anyone point me towards best practice/resources for level up mechanics?
What I wanna do:
Player collects specific item -> Level Up, set of stats changes, but to specific stats, not math
Im not sure if I should just overwrite stuff like movementSpeed in my playerscript etc.
Thanks :)!
if the item changes specific stats, then it should hold a list of those stats and the value it adds to them . . .
And then I just overwrite them on the playerscript? or do i make a seperate system for that
Tryna go for the cleanest setup, dont mind writing a little more code for that
You can have stats configured with your item configuration and the correct stat can be retrieved using the players level.
how is it configured currently?
Okay, that makes sense, thank you!
Not at all actually!
Wanna get some insight before I get started.
Theres 4 levels basically, and it would go smth like
0: speed = 5, drag = 1
1: speed = 12, drag = 1.5
etc
Do i just make a list of tuples in the item class and give my player a levelup method where one of the tuples is passed in?
No ideally you use scriptable objects or some format of your choosing to configure data for items/weapons/stuff
Then you dynamically look up in some data structure the correct stats based on player level
Ahhhh okayokay. Thank you so much!
why is there no C# script
ok I found it but why is it so hidden
All tutorials have this option immediately
nvm this does not work
Likely a different unity version.
its the newest one tho? 6.3
I mean different to the one in the tutorial
ok, how to add a script in this version
It's in your image
Scripting category probably.
Create > Scripting > ...
it says it doesnt have monobehavior
MonoBehaviour is just a class.
I usually create scripts via the ide anyway. I don't remember the last time I created it via the editor.
What and where says that though..? You'll need to provide a bit more details on what you're doing...
ive got it cuz I created empty script earlier
but thats stupid why not keep creating the script as in earlier versions
Got where??
now its more clicking
I meant that I found it
The menu just moved to its category. Nothing else changed.
I fixed it
They made it more specific
how to fix that
have you googled that
no
well
My advice, use the "Generate C# class" feature, put it somewhere nice in your Scripts folder like an "Input" sub-folder
Manually subscribe to (on Awake is the way AFAIK), or even interpret and store in variables, all the stuff you need up-front
For example I like to just have one "InputReader.cs" component (script),
And in there I have variables like Gamepad Left Stick X (float), Gamepad Right Trigger Held (boolean), etc
And wherever I need them I can just grab a reference to that InputReader instance.
Could be on a Singleton if that's how you roll
it's not neccasarily bad advice but i don't think that's what their problem is here
I figured they're following some out-dated tutorial,
Just trying to hint towards the right path
Completely new to Unity so excuse my ignorance, I'm creating a game similar to Terraria for a school project, what would be the best approach to creating a weapon system? Like would I have stuff like weapon aiming, shooting and swapping on the same script or all on different scripts? As for creating the weapons I'm planning to use 4 different scriptable objects (melee, ranged, mage, summoner) to create instances of each weapon, is this a good approach?
Hey - I apologize, but I still need some help regarding this. Could someone please look at this for m?
It just sounds like a timing issue. Are you 100% sure things are happening in the order you intended?
You can use Debug.Log to confirm
Well you will definitely need "state", i.e the state of things such as your character, which weapon is equipped, if the weapon is ready to fire, firing, reloading, etc
I’m not, so I’ll check that asap
And weapon slots, in other words attached to the character places where the weapons can be equipped.
That would connect to the inventory surely
If your not familiar with inheritence that's a concept you'll very much need for this kinda thing
I believe so, I know how to use stuff from one class in another
what do you mean by that
Inheritance is more like "melee, ranged, mage, summoner" are all a "Weapon" type.
Also im confused as to why you would need 4 scriptable objects for the weapons? In Terraria the weapons are mostly divided into
Melee and Projectiles
Tbh I wouldn't do that, I meant more on a case by case weapon basis
Or depending on your architecture they can just implement some "IWeapon" interface that requires certain methods like fire, reload, etc
Likely need some kind of "IEquippable" interface too, maybe if you can equip other kinds of items too.
I mean am I right in saying that's the whole concept of inheritance? Like for example I would create a base weapon script with core stats such as damage, knockback, crit rate etc. and then each of the 4 weapon types will inherit these attributes and then have their own seperate niches.
even then that's really one thing code wise, just melee things that don't spawn projectiles and do contact damage and melee things that do spawn projectiles and dont do contact damage
and melee things that do both
It's diagram time 
venn diagram lmao
I'd have melee as strictly true melee
Correct but you'd also want to do the same idea but with functions, ideas like OnPrimaryFire, OnSecondaryFire etc.
does not matter in this context
may someone help me, my unity wont start up, it says
Shader compiler initialization error: Failed to launch UnityShaderCompiler.exe shader compiler! C:/Program Files/Unity/Hub/Editor/6000.3.0f1/Editor/Data/Tools/UnityShaderCompiler.exe
Youre on the right track but your classes need more abstraction
I was talking to the other individual.
And yeah as kuzmo said earlier there's no reason for you to have 4 seperate scriptableobject types for your class types, the class types don't mean much code wise, personally i'd probably have a scriptableobject that defines the name of the damage type, icon etc. like ScriptableClass and have your items have a serialized field for it so you just put in the type it is
Could you elaborate on that? Is it just the same thing? the primary and secondary fire would be defined in the base class then each subclass would inherit it and like override the behaviour
Apologies btw I'm like completely new to Unity
correct yeah, on potentially a per weapon basis or some middle ground between that (eg. maybe 1 inheriting script for all gem staves)
Honestly you should probably have a base class that is defined as just a usable item
or "Equippable"
which could be under "Lootable"
equippables in the context of terraria would be a different thing
🌺 Python error
🖥️ 🔥 C error
"Useable" which would comprise "Weapon" and "Consumable" and "Block"
Yeah but they all share properties
I mean just Item is fine
goddamnit, tip of my tongue lmao
Honestly idk why i couldnt think of it either
Usable made more sense for some reason
Lol
i thought of consumable first and worked backwards to usable
What about a trap door that u can press E to open / close...
Interactable
Yep
so we got
Interactable (can be interacted with)
Lootable (can be looted into inventory)
Equippable (can be equipped)
Place-able (traps, blocks?)
What you have in your inventory and what is placed in the world are not the same
Lootable is not a thing that needs to be defined
town npcs and trapdoors/doors might be handled in similar ways in terraria actually, they have a very similar UX
interactable is all of them
fair enough i can rock with that
equippable is just a bool and flavour text esque
so you can just differentiate with a Boolean or something
equippables aren't interactables
well... you'd need to define what "Interactable" comprises
to me, that sounds like only stuff in the world
Well you have to interact with an equippable or lootable item to loot it ...
Or is that not the same lol 🤷♂️
Thats something else
With full respect i don't know if much of what your saying is helpful for the initial question
then everything is an interactable
Both need to show some "press E to interact" or "press E to loot" no? Same detection behaviour
the same object to the player muight be many objects to the game
you need to make a useful distinction
Idk in a lot of games you press E to open a "nearby" door, same way you press E to loot a "nearby" item.
But okay guys.
like a fishing rod on the ground might be intractable, but interacting with ti just removes it and adds a item to inventory
i thought we were talking about terraria, where equippable is not a property of stuff in the world
we are talking about a specific game
Also in terraria interactions happen through left clicking
i don't know what the original question here was
general terraria item code composure
oh cool, ontopic then (somehow)
Person didn't make it clear they're making a 1-for-1 clone. But okay.
I'm just here to provide options alright.
Ehh dk just seemed most reasonable at first glance. I was planning on having melee weapons stictly melee, ranged weapons strictly bows and guns that fire a projectile, summon self explanatory, I kinda see how mage would overlap with ranged tho, main difference would just be resource usage.
i just saw "melee, ranger, mage, summoner" above and went straight to terraria
they did and everyone else did
There is no difference between ranged and mage
code wise it's all really the same thing asa base
Or melee and summon (whips)
yeah makes sense
or mage and summon (uses mana)
summon as in the staff that summons a minion
whips are also summoner class in terraria
Still just an item with OnLeftClick function
ahh ok that makes sense
That does something
summon staff use, melee use, placing tile, using potion etc. all derive from a base OnPrimaryUse / OnLeftClick etc. etc. behaviour
yeah I see how they all the same now 😭
Can i make this world space UI element appear in front a 3d object in the scene? Layers don't seem to work.
So in general is there no point having separate weapon type classes? The weapon type would effectively just be flavour text? (apart from type specific damage)
I'd also like to ask what's the best way to create weapons? Like would I create a different prefab for every single weapon? Or just have the assets with the base stats, and then haved the behaviours as a bunch of modules
-
Mostly yeah, there's some stuff that will come up when you calculate damage where you need to see "what" type it is but for the most part it's just a association
-
no one answer but probably a prefab for every weapon yeah, at least for someone starting out
Prefab per weapon is a sound approach
I like having a Scriptable Object that describes what the weapon does like a WeaponStats or something.
For example fire rate, or what projectile (prefab likely) it spawns if it's ranged, etc.
Yeah that's what I've got so far
as a freebie example for the inheritance talk, here's how you might approach handling potions.
green are virtual functions and blue are overriding functions
you can see how you could set up base functionality and have layers of inheriting classes extend ontop of it as needed
You can try seeing if urp renderer feature will work.
camera stacking might also me an option but I'd probably try former first..
ahh that's very helpful thank you
i think you have green/blue swapped in the description?
don't worry I gathered 😂
how's this a unity code beginner question ?
damn wrong server 😅
stats for what?
not fully tested but heres the result
Whoa that's awesome. Is that all that's needed, the "Render Objects" thing? No double-camera?
yes exactly its a really powerful feature if you use URP , no more camera stacks even for weapons / fps doing that
Would there still be a way for certain objects like walls to occlude the object?
I think so cause you're playing with depth
before normally you would do this via shader code / render queue, this simplifies everything a bit
Quien a creado juegos poderosos
english only server.
first time using unity
can anyone tell me why is the movement jittery?
rb.linearVelocityX = Movespeed.x * speed * Time.deltaTime;
rb.linearVelocityY = jumpheight * Time.deltaTime;
```Move this to FixedUpdate, because it has to do with physics it shouldnt go in Update(). If one player has 10fps then the physics will calculate 10 times, but for another player with 60fps theyll get 60 physics updates. FixedUpdate will keep that consistant regardless
On your rigidbody settings, set Interpolation to Interpolate
there may be more reasons contributing, hopefully someone else can respond with more
Don't multiply velocity by deltatime. Having it in Update is fine
Thanks
I'll try that
when I run the game the particles appear like on the left but when I just play the particles its like the right. why dont they spread like on the right ? The particles r played when the ship is moving btw
Is there a way to tell if a scene is loaded OR currently loading? gameObject.scene.isLoaded is false in Awake.
All Awakes run when the scene is already loaded. You have to load the scene async if you want to track the progress
nah scene.isLoaded says it's true only after the objects have been enabled and awake runs before the objects have been enabled when loading a scene
What do you need this for? If Awake runs then you already know what stage the loading is in
Well the issue is I have some code that's not in a monobehaviour that checks some stuff with a scene struct but the scene struct doesn't say it's loaded in Awake when i call that code
Then do it in OnEnable
nah I can't it's false in OnEnable too, it's only true after OnEnable is called
Run Start as a coroutine and delay it one frame
Its true in start but its nice having the seperation of awake and start yk
yea i usually keep awake for "me" telling "others" about me and start for "others" asking about "me" if that makes sense
But if you can't run the code on the frame when Awake runs then you can't really use it then
yea. this monstrosity works tho but i gotta find a diff way eventually
//TODO: fix this workaround
public static bool IsSceneLoadedOrLoading(Scene scene)
{
try
{
var gameObject = new GameObject();
SceneManager.MoveGameObjectToScene(gameObject, scene);
UnityEngine.Object.Destroy(gameObject);
return true;
}
catch
{
return false;
}
}
why would they make the scene api that wack
Probably because you shouldn't really need to probe it from outside the entry points that unity provides you with.
Could you move the execution order of your scripts, so your onenable of the desired script is called at the right time and true before you trying to access things?
i just want to check if a scene is loaded inside the entry points but not tied to monobehaviour logic :(
What entry points are we talking about here?
awake
Then perhaps what joer said. Make it the last awake to run via execution order, then you'll be sure all other awakes are complete.
When Awake runs the scene is loaded for all intents and purposes. If you want to make sure all Awakes have run then that's a separate issue (and what Start is meant for)
yea i guess its just weird that scene.isLoaded is false until the last OnEnable
Makes sense to me in terms of relying on the scene to be fully loaded and accessible
It's meant for monitoring the load status from outside the scene, where you're more likely to want for the gameobjects to be fully initialized before continuing. It doesn't make sense to use it inside the same scene that's loading because whenever you can do anything inside the scene it has already loaded
It is odd that unity doesn’t have any proper callback for when a scene is accessible but before objects are given messages
How do you stop emitted particles from rotating along with the emitter
looking into it more, IsValid is the proper call. A scene that is not loaded (when accessed properly) will not return a valid scene struct, which is confusing tbh
There is still no callback like what i mentioned but glad you resolved the issue
Curious should i be concerned. This has been on the back of my mind. But whenever my project recompiles while i'm running it, all my coroutines stop running, could this happen if say my game was left running in the background for long enough as well?
Recompile and keep playing is shit and doesnt work properly unless you do things in a dumb way.
Change your settings to recompile after playing. You need hotload plugins to do this properly
That sounds interesting. I'll have a look.
Recompile while playing has never worked or been worth using
Is this the appropriate channel to ask for help with HLSL basics in Unity URP?
I dont think so, but I also dont actually know where you should go
Theres an old archived channel for shaders but no new one
Hmmm okay
Ask here
I have a quick one
Ive just watched a tutorial where the programmer writes an if statement like this
Why no curly brackets?
Dont need it for one line
Yes
Perfect thanks
Alright- What does this syntax imply? I'm not sure what to search for.
Here's the struct for context
Well im not really well versed in hlsl but the underlined line just looks like youre setting all the struct fields to 0?
I guess
Oh that might well be it
I'm looking at someone else's code so I didn't write it
thanks!
Ah thanks, I couldn't find the right channel before
hi guys, does anyone knows a good article or doc on handling Slopes with character controller? Ive been trying to make it work properly for a time now and i searched a lot of videos about it, but everything just breaks a part or sounds like bad practice, like making the jump break because of gravity forces and so on. I just want a Character to be able to stick to the slope, not bouncing on the way down
I have always used the Brackeys video
Let's see how to get an FPS Character Controller up and running in no time!
REGISTER with APPTUTTI: https://www.apptutti.com/partners/registration.php?utm_source=brackeys&utm_medium=social&utm_campaign=brackeyssponsor1
LEARN MORE: https://www.apptutti.com/corporate/?utm_source=brackeys&utm_medium=social&utm_campaign=brackeyssponsor1
● Ultim...
Never had any issues
Could you describe what you mean by bouncing? maybe finding out why that happens would be helpful
In the meantime, I need some help
I am trying to read the mouseposition difference from one frame to the next
unfortunately my variable "difference" is just coming out as 0,0,0 and im not sure why
Just so you know the stuff happing in the first and second if statement happen in the same frame every time this function is called
Meaning difference is equal to value - value so (0, 0, 0)
Unless they are negative
The operations are the wrong way around. First calculate the difference, then set the dragOrigin to the current value
Yeah I can see what you mean
Ill try this
OOOO
Perfect
Thanks
Works like a dream
Hi! So this is my script and the "Sprint" action is throwing an error, more specifically " NullReferenceException: Object reference not set to an instance of an object
Player.PlayerMovement.Update () (at Assets/Scripts/Player Movement.cs:29) "
public class PlayerMovement : MonoBehaviour
{
[SerializeField] float WalkSpeed = 4.5f;
[SerializeField] float SprintSpeed = 4.5f;
[SerializeField] InputActionAsset inputActionAsset;
private InputAction MoveAction, Jump, Crouch, Prone, Sprint;
//Rigidbody rigidbody;
void Start()
{
MoveAction = inputActionAsset.FindAction("Move", true);
Jump = inputActionAsset.FindAction("Jump", true);
Crouch = inputActionAsset.FindAction("Crouch", true);
Prone = inputActionAsset.FindAction("Prone", true);
Sprint = inputActionAsset.FindAction("Sprint", true);
//rigidbody = gameObject.GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
float speed;
if (Sprint.IsPressed())
{
speed = SprintSpeed;
}
else
{
speed = WalkSpeed;
}
Vector2 moveValue = MoveAction.ReadValue<Vector2>();
Vector3 moveVector3 = new(moveValue.x, 0, moveValue.y);
gameObject.transform.position += moveVector3 * WalkSpeed * Time.deltaTime;
}
}
Which line is 29?
"if (Sprint.IsPressed())" is line 29
Then it didn't find an action called Sprint in Start
I moved it to be below the MoveAction, and it works!
Thanks
It was there and everything but it didnt find it which is very weird
Wasnt it already? Wdym
Like directly below it
i cant figure out how to make jump
using UnityEngine;
using UnityEngine.InputSystem.XR;
public class CharacterChontroller : MonoBehaviour
{
[SerializeField] CharacterController pCon;
[SerializeField] float speed = 6f;
[SerializeField] float turnSmoothTime = 0.1f;
private float jumpHeight = 1.5f;
private float gravityValue = -9.81f;
private bool groundedPlayer;
private Vector3 playerVelocity;
float turnSmoothVel;
void Update()
{
groundedPlayer = pCon.isGrounded;
if (groundedPlayer)
{
if (playerVelocity.y < -2f)
playerVelocity.y = -2f;
}
float horizontal = Input.GetAxisRaw("Horizontal");
float vertical = Input.GetAxisRaw("Vertical");
Vector3 dir = new Vector3(horizontal, 0 , vertical).normalized;
if (dir.magnitude >= 1f)
{
float targetAngle = Mathf.Atan2(dir.x, dir.z) * Mathf.Rad2Deg;
float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVel, turnSmoothTime);
transform.rotation = Quaternion.Euler(0f, angle, 0f);
pCon.Move(dir * speed * Time.deltaTime);
}
// Jump using WasPressedThisFrame()
if (groundedPlayer && Input.GetButtonDown("Jump"))
{
playerVelocity.y = Mathf.Sqrt(jumpHeight * -2f * gravityValue);
}
// Apply gravity
playerVelocity.y += gravityValue * Time.deltaTime;
}
}
Is groundedPlayer ever true? Try logging where you do the jump and see if that code is ever executed
you don't see to be using playerVelocity anywhere, you aren't applying gravity
that pCon.Move shouldn't be in that conditional, you should call Move once per Update
oh i figured it out thanks
Is there any reason the Move is called before the jump action happens? Wouldn't this just make the game feel like it has extra input delay?
i have this problem , unity is saying the variable is not assigned in the inspector but it's there in my inspector , anyone know what this could mean?
It means there is a Single Weapon Controller that does not have secondaryPoint assigned.
Since the one in your screenshot does have it assigned, that is not the one the error is talking about.
ah yes , i love unity for putting the weapon controller on a mesh , tkx.
i didn't remenber that unity does that sometime
It doesn't
Unity doesn't just put random components on unrelated objects.
might be me from 2 day ago then , anyway tkx
Is old input system bad? Im a beginner following an old tutorial and should I just follow the tutorial or try to make the movement to the new system
@polar acorn maybe u can help
the old input system works fine so its probably better to just use it to learn from the tutorial
please don't ping random people for help
the new input system is "better" but much more confusing imo
well I saw that he helped someone 4 mins ago
what makes it better? what is the difference between the two
something something controllers im not sure tbh tried to use it and gave up
but for learning something from a tutorial your input doesnt rlly matter that much
it's not bad, that's very subjective
it's simpler and less flexible - flexibility comes with complexity
and that's what the new input system is, very flexible (very powerful) but also more complex
if you already have a tutorial using the old system, just go with that - you can worry about learning the new input system later
you should learn the new input system eventually though
ok thanks
that's called codelens
yes it is called codelens
you can search for that in settings
you can either disable codelens entirely, or disable the unity extension from providing codelens
It may be something in the VS unity tools options, it not then code lens has to be turned off entirely
ok thanks I found it in unity plugin settings
it is under TextEditor > All Languages
oh yeah, thanks
i have it also disabled
can someone tell me is there a way to fix this game window to have rounded edges?
like I see that this is prob for performance
but if I'd like to see the actual game resolution, how can I do that?
thanks
also looks like you have antialiasing disabled which creates those rough stepped edges
or the scene view is zoomed in
oh yeah that could be, on the right of the resolution the scale slider should be at 1 if you want to see what it would look like
Configure is strong words it wont stay as the last set resolution when you build and ship the game
But yes this is an easy in editor way to test resolutions
is there still a locking layer unity option? I can't find it
this is a code channel
ask in #💻┃unity-talk
ok
!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 #🌱┃start-here
and don't ask to ask
I'm trying to use Quaternion.Euler, but are rotation around the local Transform
How can I change to rotate into Global Transform?
I'll send the code
this isn't a social space, you can include pleasantries if you want but just start with your question
Oh, okay, sorry about it :/
I was typing the question in a new line
Quaternion.Euler just gives you some rotation. quaternions aren't inherently local or global
like, a Vector3 isn't inherently local/global, a position isn't inherently local/global
a local position is local, a global position is global
what matters is how that value is used
sure, you can do that. try not to do it in a separate message
I'm new with Quaternions, wo, I'm confuse a bit
That's my code
newRotation are in the local axis, but I want to uses this value into global axis
!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/
📃 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.
please share it properly
Ah, ok, let me adjust
(unrelated minor issue) that code is using wronglerp, this will result in framerate-dependant and asymptotic behaviour, of which the second might be an issue, and the first is definitely an issue (though probably minor)
Done
I believe that the issue is in the line 60
The first image is the Local Axis
The second image is the Global Axis
I'm trying to rotate into the Global Axis, but I don't understand very well how to do this
a powerful website for storing and sharing text and code snippets. completely free and open source.
rotate into the Global Axis
what do you mean by this?
I'll record to be easy to demonstrate
the issue here might be due to how rotations compose
i'm not super familiar with quaternion math, but iirc:
quaternions represent rotations
a * b represents rotating by b then rotating by a (or rotating b by a)
so as you multiply in those new quaternions on the right (what *= does), that looks like rotating on the global axis, and then rotating according to the original rotation of the object
transform.rotation is already global
if that's the case, you could make the new quaternions multiply in on the left instead, like newRotation = Quaternion.Euler(...) * newRotation;
Here the video
In the first part, when rotate into Local Axis is okay, but I want to rotate into Global Axis to avoid this angle issue in the second part
what?
changing the tool setting in the scene view does not affect any behavior ingame
Yeah, I know, was only to demonstrate what I want
that local vs global setting just changes whether the rotation gizmo in the scene view shows handles aligned the existing rotation of the object in its local space, or if the handles are aligned to world axes
I don't know how to adjust it to Global instead Local
Because I want to use the Global Axis instead Local Axis
But I don't understand how to do this in the code :/
have you tried this
i don't think i'll be able to give any other answers past that, it's pretty late for me
in general you wouldn't be compounding quaternions anyways
Is multiplying already by itself
the typical approach is to store the pitch/yaw, and apply a wholly new quaternion rather than modifying the existing one
a * b and b * a are not the same for quaternions - multiplication isn't commutative
Hm...
Let me try inverse it
with this approach you can also limit the pitch so you don't get an inverted camera
i'd recommend looking into that
Oh god!!! Awesome!!
It works perfectly!!!
Very, very thank you \o
I wouldn't imagine that works different with the calculation order
Very thank you by your help ❤️
also look into this approach, would be simpler
also consider looking into replacing/avoiding wronglerp
I'll adjust with your tips too
Thank you by your time, bro \o
Greetings to you all, I'm just asking if learning to code on unity from scratch is worth it? i read #🌱┃start-here and #📑┃channel-directory and this seems most relatable to this question, im about to ask another question in a channel most related to that question.
I'm trying to make a simple left and right movement system for my game but I can't find any good tutorials on how to do it because they're all outdated. Can someone help please?
like learning to code based on no prior knowledge or what?
I mean i know the basics of lua such as but not limited to: Variables, functions, function scoping, tables (wasn't too strong on tables), and most likely more I can't name off the top of my head
But im mainly asking if i should dive into a brand new language
Specifically for unity
Specifically so i can make stuff for vrchat
Always good to broaden your horizons and learn multiple languages
Yes
since you have the basics down it’s actually quite easier than you think to get into new languages
My good sir YOU WHAT
Also
I have infinite potential
Join the growing VRChat community as you explore, play, and create the future of social VR! https://discord.com/invite/vrchat
ah
As it includes coding too
well yeah learning a new language is always good
I know what kind of man you are
I heard c's are used for many things
Im done wasting that potential on....yea-ing
Im gonna lock in and change the platform
c# is what unity uses yea the c’s are quite similar tho
Alright
Im gonna assume your a programmer without looking at any of your roles, how long have you known c# for if you know it?
Could you help me with some C# after you're done?
sure
around since 2019 but it’s a constant learning thing
try to not target one person on here to be your helper
01 15
2025
2019
ask for help generally for anyone to assist with
Damn so 6 years
I did but nobody responded
yea pretty much lol but time spent does not matter I’m sure there’s people way smarter than me who know more in less time
regardless
Yes
you should learn c# if that’s what you want to do
doesnt matter.
Creating movement is quite fundamental and many tutorials cover this topic
I just dk
I feel.... lost.
The thing is whatever i choose i wanna go all out on it
that’s a good thing you have motivation
Half of the ones I looked at either made no sense or used the old input handling thing
or in my previous case were just bad
since you have the basics down just start working on something and you’ll figure it out eventually
Basics of lua
Even if c# or unity isn’t your thing you’ll still gain more transferable skills
I have 0 knowledge on c#
All languages have the same fundamentals
Where would you recon I begin? I have some time now
@upper pebble Unity learn courses like this use the new input system:
https://learn.unity.com/course/2d-beginner-game-sprite-flight/tutorial/set-up-your-2d-game-world?version=6.3
Free tutorials, courses, and guided pathways for mastering real-time 3D development skills to make video games, VR, AR, and more.
Except for malbolge 😭 that shit is just computer gibberish
Microsoft has some good ones if you want the just c# but also people recommend unity learn for both
hi is there some way to rebind an input action to a different key in a script?
🙏 thank you for everything
np lol and good luck
Last question, do yk of any youtubers that do videos on unity?
Is it possible to only allow certain functions to activate if something is true?
More specifically, I have DragHandler functions with OnBeginDrag, OnDrag, and OnEndDrag, and I only want those functions to activate if a certain boolean is true. Do I just need to add a return statement in an if statement at the beginning of each function or is there a better way to handle this?
There should be a way, it supports exporting and importing action bindings at runtime
yes check the bool yourself with if
brackeys I think but you’ll have to find ones that are good for you
Videos are verrrry ranged in style and structure
Definitely heavy on the very ranged part
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
When it came to lua coding some youtubers would just confused the heckles out of me, while others it clicked instantly
yeah so you have to find what works for you
That doesn't cover what i need
Id just learn c# with microsofts stuff first
True yes, but he may have had insight from a personal experience
me personally videos just don’t stick
But also nothing will stick unless you’re making things as well
Definitely this, yes
This one is even more basic and will teach using input to move something https://learn.unity.com/project/roll-a-ball
Free tutorials, courses, and guided pathways for mastering real-time 3D development skills to make video games, VR, AR, and more.
https://learn.microsoft.com/en-us/dotnet/csharp/
this is good for understanding just how c# works a bit before getting into unity
I also recommend you shouldn’t make yourself finish the whole course because you may never need some stuff
if you want to then that’s good too
I kinda miss getting frustrated coding, spending 6hs to fix an issue that took 6 minutes to fix
still learning
You know what to do next time now
and those times probably won’t stop too
when you go onto harder concepts
Facts
where do i go when i find no help in the troubleshooting pages? I'm just starting the coding essentials in the unity tutorial and am not sure what i did wrong despite watching the tutorial and re creating the code
here
you can ask questions
so on the right are the instructions, which i do and it doesnt auto populate the " (collider other) { " part in the code, so i put it in manually and it makes the "0,rotationSpeed,0" line not function
Whats happening
!ide
If your IDE is not autocompleting code or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
It mentions you'll only get auto complete if you have a configured development environment
If you don't you'll have to do it manually as it shows, but you really should just configure the IDE
coolio thank you
Besides it actually working is there another way to tell if its workin?, I believe i did it but the IDE is still not functioning, even though i have it listed as the external editor, although instead of it letting me go through the Unity editor files, it made me go through my pc files to find it. it currently is installed on unity hub as well.
maybe the package isnt installed properly?
check in the package manager for the visual studio ide package
it should be preinstalled but just check
you can search for them
Why is it saying this? I'm trying to follow a Unity tutorial and this never popped up for them and I KNOW I followed the steps correctly
Wait do I need to change the thing to rigidbody 2d or something for this?
Rigidbody not RigidBody
CapItAliSation MATTers
thx. Guess I was looking at the wrong spot
Welp it doesn't move even when fixed. Back to the drawing board
Aight I def need help with this. Is there a call I can get into to make this easier to communicate?
not really, no and the server doesnt allow soliciting dms
there used to be an offtopic but apparently it was too toxic so they made it more of a "professional" help space
I feel like it'd be more professional to allow for screensharing at least
regardless you'll have to share screenshots and code if you need help
How can I get this to work on a 2D space and only work left and right
Also that's wild that they don't allow people to talk in dms
!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/
📃 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.
This is wrong too. You need to read more carefully and match capitalisation
is your IDE set up properly?
!ide
If your IDE is not autocompleting code or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
it should be able to autocomplete tehse things
haha ofc its not set up
(example)
wtf is that font ew
Man idk. I had to use this software for a class I took last summer but I don't know how to switch off of it
comic mono, i have unironically been using it even though i set it as a joke
follow the instructions the bot sent
^do that
I feel like a new kid who just got thrown into a professional Esports team
so i looked and all i see is the folder packages > packages.unity.com > then big list of "com.unity.blank"i see visualscriptin@1.7.8 and "com.unity.ide.visualstudio@2.0.16" Is that what im looking for?
you're looking in the wrong place
click on this button (colour doesnt matter)
search to see if the visual studio editor package is installed
on the "In Project" tab
it is not, but it is in the unity registery, i assume get it from there?
THANK YOU HOLY MOLY
lol np
Okay I fixed the thing but it still has errors connected to RigidBody
Did you like insert the rigidvody component into the slot of it in script in inspector?
I added the component using the "add component" button after clicking on the object
Wait that's not what you were asking was it
you are trying to get the 3d rigidbody type
its Rigidbody2D
i doubt the unity tutorial fucked this up
Ahhh I see. That's what I was asking earlier but it got drowned out by my capitalization issues
If you have a tutorial to follow then make sure everything matches, they usually share all the code as text too so you can copy things
It didn't, I just got tired of asking for the same thing but getting different results. If you scroll up, you'll see I was asking for 2D examples but you kept giving me the wrong tutorials
I mean did you like reference the player rigidvody component into script? Idk this could be related to problem or maybe I’m js slow
First time creating a game, I'm tryna make a simple topdown roguelite style game.
I've got player movement down and I want to create a weapon system, I plan to just have your standard ranged weapons (guns, bows, staffs, tomes) that fire a projectile, and then some melee weapons that swing about a pivot to attack. Sorry this is a rather broad question, but what would be the best approach to creating this weapon system? As far as I've seen weapons can be created in several different ways and it's a little overwhelming.
I did but the search engine is a little stupid or I'm searching for the wrong thing
LMAO SAME AS ME
At your stage id just follow a tutorial from them from start to finish to learn some things
I sent roll a ball as its short and teaches input and moving stuff with physics (a shared concept in 3d or 2d)
yessir
I was originally trying to follow a YT tutorial but it was using the old input handler thing so I didn't realize that was a problem until much later so I had to improvise with this
any way to make a rigidbody fall faster to the ground without changing the projects gravity
Add downward velocity
I’ve tried (and failed making a couple games lol) either from losing motivation or a problem that forces me to restart project lmao (this is why you don’t use a Rigidvody movement script from 5 years ago that causes stuff to mess up (especially with procedural animations), also don’t use ai it kinda messes stuff up and makes me feel like I did nothing). don’t make the mistakes i made lol.
Let’s hope the next one I improve and actually make it okay-ish
Lowkey used the built-in GPT-5 thingy in VS Code just to see if it was good at all and I managed to make a far simpler and easier to read thing than it. What a waste of electricity and water lol. I barely even know how to code
you're in #💻┃code-beginner dude
Either setting velocity or using AddForce
no i know that i cant though
why not
is there another way in the rigidbody settings
weight? i dont think that does anything though
why are you asking for non-scripting methods in the coding channel
where else
#💻┃unity-talk ? although i feel like you should just be using code anyways
why cant you use code?
I’m like ok at coding, cause of experience, not cause I learned C# in unity for tons of time. (Like 2 years of experience but im like meh lol) I should start relearning lmao
Ye just make sure you don't use any A.I for the actual code. If it can't make a line of code better than a near-beginner programmer then it's trash
if you have a brain you're immediately better than any gpt model. gen ai is a buzzword that allows billionares to ruin the planet
I can 😭 I only used ai once and that was when i was lazy and tired of trying to make animations (cause im bad at em)
procedural stuff idk
Valid
Ai is js a way to ruin your project and get more regrets in life
How do i make the object move faster? It accellerates extremely slowly
Increase the force you're adding
I am sorry for what I am about to say, but how would I do that
use bigger numbers
We love rv.addforce.
That's what the tutorial requested :(
Love RB, hate PID controllers 
I can’t type the letter that’s meant to be after r in the thing (phone keyboard broken)
Lmao
I know there's a simpler and better way but my memory is way too foggy
Like I used to do this all the time but now it's just... gone
ForceMode.VelocityChange is a useful one
.... where would I add that? I'm guessing replace it with rb.AddForce(movement);?
Never heard of it, do explain please?
It’s on Unity docs better than i can explain.
But i recall it ignores mass
Nonono you’re fine I think
Ooo
Double jumps ahh
ForceMode goes into the 2nd parameter of the AddForce function
It’s an optimal parameter default is uhh ForceMode.Force I think ?
Yes
Impulse is good for like short bursts or like pushing things with gravity and stuff (I think) (so like jumping and wasd)
I don’t remember cause I didn’t code in like 5 months after I kinda accidentally destroyed my 6 montg project accidentally
Hard to bounce back. But I wanna finish one game in my lifespan
AFAIK VelocityChange is identical to Impulse. just that it doesn’t consider mass
Unity Docs imply that in their wording “In contrast to ForceMode.Impulse . .”
I am Frankensteining code together
IT WORKS HAHAHA
IT'S ALIVVEEEEE
How do I make this monstrosity have a movement speed cap? I tried something at the bottom but it doesn't seem to do anything
could anyone help with this?
Choose the simplest way and start working on it. Then test to see if it's satisfactory for you or not.
@upper pebble
You probably want velocity magnitude.
This could work
I'll try it
Kinda. I'll show you in a little
Ok
ehh that's the thing I'm completely lost, most tutorials seem to be very specific and don't bother explaining anything, I need some level of futureproofing but I'm not really sure what would be a good approach
Then take the shortest tutorial and implement it. Then work from there. You should be able to understand how it works by reading the code and reasoning about the setup in the editor.
The friction I have is essentially an instant stop lmao. If you look at the code it should be towards the bottom
ok thank you I'll give this a go
For some reason the player still moves a bit after switching directions or stopping input and the speed cap is NOT working :(
Maybe like instead, slow down the player by a small amount, ex: float friction = 0.03 and use time.delta.time to like slow over time?
I don’t remember fully lol
I have no idea how to implement that
My issue is:
- It's ignoring the code that is supposed to stop it on occasion
- The speed isn't capped
I keep accidentally pressing enter lol
Speed isn’t capped?
It isn't :(
If you're moving using force, you need to check the velocity and stop applying force when it reaches your maximum speed . . .
True lmao I’m bad at this
Okay so I changed some values and the max speed works when I move to the right but not the left...
How would I do that
So, when you move right you’re moving negative technically no?
Y is max speed so low
I needed it to be obvious
True
Well hmm.
Maybe like cause you’re moving backwards the velocity is becoming negative?
Idk
Lmao
I need to relearn
Ye lemme create something rq
Alr
@upper pebble you could use this idea?
I have no idea how to use it
IT WORKED
YES
YES I FINALLY HELPED SOMEONE
I’m so proud
Of both of us
I can’t believe I helped someone while I’m in an airport tired af lol
I just need to make it accellerate faster now
Yeah
Inheritance, interfaces.
Detection of nearby “things” (game objects or better yet prefabs, usually with colliders so that you can use the Physics system for the detection)
Logic to be able to “pick up” the nearest “thing” upon pressing a button or w/e
pick up into where? An item slot or multiple slots.
Or to the inventory
It’s all online for sure. I’d avoid “complete” tutorials and do it how you like piece by piece, step by step
Yeah you do tutorials that explain a small part, then you learn from it and incorporate it into how you want to make code better
E.G: interaction colliders, ray cast, idk
add larger values
where is your acceleration?
is it the movement var?
multiply that by something
I think
And by the way, movement has nothing to do with speed in your setup. Your max speed logic doesn't do what you think it does.
Bigger numbers always better (unless want small numbers or you get an error relating big numbers)
Explain
I’m also curious
Truely am curious why there aren't any calls for this type of stuff
Probably clamping velocity not movement? or worse acceleration?
-# how are you writing this code and not knowing how it works?
I'm balling on the courtyard that's how
Brain cell loss?
In your code movement is just the input/direction. The speed that your rb get is calculated from force. Normally, it would increase every frame. Speed == velocity magnitude. You've been told that several times now.
(I have no idea what it does)
can someone pls help on #💻┃unity-talk ? Its a question about how to make folders in hierarchy
So I need to change it to speed rather than force
Can you please avoid unrelated comments? And suggesting solutions when you clearly have no idea. You led them into misunderstanding about their code and writing incorrect logic.
Sorry…
There are many ways to go about it, but generally, you can check the current speed, by checking the velocity magnitude.
No they didn't? We found a solution that didn't work the way we wanted but it did help.
Some humor also goes a long way
If it's above your max speed, you can avoid applying force. Though you'll have to take into account it's direction too.
If you want a simple solution, set velocity instead of applying force.
hey guys waht is a still working version of FindObjectOfType?
FindObjectsByType i believe
Probably that still works fine you’d just want the 0th item then 
just check the docs of your unity version. search the Object class and look for the method(s) . . .
thanks
I just moved to unity and wondered if someone had some insight about parallax for 2d platformers build in a 3d space. Sorry if my question is long and vague. I am trying to make a parallax system like hollow knight/ori. Apparently, hollow knight uses Orthographic camera, which avoids distortion, object scaling, and Z-fighting. Meanwhile Ori uses perspective cameras. Seems like orthographic is the right way, but a lot more tedious, and there is no tutorials, as most youtubers prefer showing the perspective way since it is a "quick hack" to get it working in 5 minutes.
So my goal is to be able to place the objects in the editor where they appear in game, and moved from game maker for that. I know Godot has a "live preview parallax" feature that achieves that, but i am more interested in Unity, in which live preview while do-able, was more problems.
The solution that i created is "camera anchoring triggers" which makes my objects in certain trigger zones think the camera spawned at different areas. Which works, but once again tedious and far from perfect. But at least my objects in editors can be somewhat close to where they should be.
So I wondered if anyone has been doing parallax with 3d layers in editor, how you dealt with layers and sorting orders.
ortho has no depth so those "perspective hacks" that convey depth arent really hacks
iirc hollow knight silksong uses a perspective camera
Ok i had a long argument with chatGPT about that haha. According to what i've found on reddit, it is an orthographic camera. How to deal with Z-fighting with orthographic, just a small FOV and far away camera?
ortho cameras dont have FOV
FOV only applies to a perspective
generally i think it's mostly just moving assets forward and backward on the z axis
It's not an issue with orthographic, just annoying sorting orders to deal with. Basically i am using Z only to build scenes and simulate stuff like fog, parallax, etc. But with orthographic moving left/right from objects can cause some Z-fighting
unless they are like super far back on depth
I tought i could do it by making them Z = 0, Z = 0.1, etc. I don't have much of example as i haven't build much yet and can't make videos.. but on this picture the selected item is Z 0.1 but rendered in front of the Z 0. It only draw behind if i make it a full unit behind, which is too much. Also, even if i had 3 column at Z 1-2-3, they would Z-fight if i move the player/camera, left and right from them. So i guess maybe i just need a low FOV and move the camera far back?
Whoa sick visuals bro. Is that your art?
I meant sick visuals They/Them/etc (respectfully)
thanks, yeah well it's from my game maker game, i'm just doing some test to see if i want to port to unity
you can avoid z-fighting. unity has 2d layers with indices to determine which layers appear in front or behind. even within those layers, you can order and group objects to appear in front or behind as well . . .
hoping to be able to do a bit more vertex displacement and better parallax in unity
Lots of great games are made in Unity. Good to hear
You’re good at art. Damn, I’m jealous
yeah i find everything much longuer to do, but i can feel the power. in game maker i am simulating a 3d camera and it's been quite a headhache
are you using the urp 2d stuff?
there is a setting in its asset to tell it how to do sorting, might want to use a custom axis
yeah, i learned about it way too late and realized i wasn't even on latest Unity version so hard to start over, but learning shader graph right now and i love it
also the camera i would adjust its far and near plane to not extend too far past your content
doing so greatly reduces the chances of z fighting
still looks better in game maker but theres so many post processing tutorials on unity i hope to learn more techniques
chatGPT has been REALLY insisting on using orthographic so i came to ask on discord lol
yeah its just a learning curve to learn a new engine
(yeah i haven't learned C# yet so letting AI code for me..)
the approach you are tarking in layering these scenes looks close to what like hollow knight does so that proves it can work very very well
like your art, its simple but carries the mood well and is easy to read
Seriously how are you cooking up these sprites
Krita?
basically spent 2 weeks coding this parallax system, while it all works right away in perspective.. but it does feel a bit weird and distorted in perspective, so honestly starting to believe orthographic is the best way on the long run
I've been doing pixel art games all my life. then i bought an ipad and fell in love with Procreate, so decided to take a shot at hand drawn animations
just looks like good hand painted stuff with a good pallet
(photoshop great too but i like spriting in my bed lol)
honestly i kind of cheat with post processing for the color palette haha
It's not giving "default brush" energy
it takes more then a brush to do that, its just experience
Then again looking closer it rly just does look like the typical "3px wide" brush 
Nice cooking for real
yeah using some pencil like brush, planning to use same brush size everywhere like a comic book, and avoid blur effects, so i'm building different type parallax fog
unity sure is opening up a lot of options
expecially if you are willing to dive deep into how render features and shaders work yeah you can do more or less what ever you want
yeah now that i can finally make decent distortion shaders, i'm thinking of trying a more paint style and go full on Ori
fancy pants, classic 💪
doing distortion per object, or writing the offsets to a buffer and doing the distortion in screen space after
per object, just like those shaking leaves and bushes in the wind
(looks terrible with outlines though)
with a mask the outline could be left alone with distortion in the middle
Ori and stuff like that also has a lot of vertex position stuff going on as well to bend things as you walk past
i'm very, very beginner with shaders, but currently it's just a height mask that makes the thing shake left and right
or shake them in wind / things that make force
yeah like when you pick up an object it all moves, super cool
(in my game it just rotates, doesn't look all that good)
visual tricks like that are often iterated on a few times in a dev cycle
sometimes makes sense to get further along with content to see it in context
for sure, i'm basically trying to do a vertical slices, not even touching gameplay
visual prototype/reality check
before ditching 3 years of work to start over lol
but yeah think it looks cool, and reads well, its very obvious what is forground, background and enemies
yeah my first test in unity is i build a fog/noise shader that colors the further Z objects in the color of the background, hopefully that will help with that without using blurs
yeah that is simple in 3d, not sure how much of these things are writing to a depth buffer though in 2d i would need to play with it to know
yeah i don't know a thing about optimization.. it's not actually using the 3d though, just using Z as value for depth simulation
i'd imagine you probably have a fair amount of tech budget to not be super optimised on that anyway, at least when learning
Yeah unity seems a lot more optimized and powerful than what i am used to. Not as worried drawing big sprites and have big scenes
Hey guys, I've ran across this confusing problem where the level manager keeps spawning levels in a completely different place then where I want them to be. But for some reason the position of the entire level tells me the level is where I want it to be, yet it definitely is not where I want it to be. I don't think it's a coding problem, but I don't know what I did wrong with it.
you need to switch this to Pivot mode
then you'll be able to see the real positions of your objects with the position gizmo
From the inspectors i can see the positions are correct (exactly the same as each other except for +25 on the x axis)
ok, thank you!
no modding support on this server, sorry
Anywhere where I can find that support
you'd have to seek that out
Wonderful.
offical server so gets into tos related stuff
Hey small question how can i find with math or code the coordinate along an segment between two point?
anyone tried using vscode on ubuntu? no matter what i do mine can't acknowledge the existence of dotnet sdk. i pinpointed the dotnet location manually in settings, i reinstalled it multiple times, i tried using omnisharp, i tried multiple other internet "solutions" but nothing works. I can trigger dotnet --info in linux terminal, but not in VScode. this is the error:
The .NET SDK cannot be located: Error running dotnet --info: Error: Command failed: dotnet --info /bin/sh: line 1: dotnet: command not found /bin/sh: line 1: dotnet: command not found . .NET debugging will not be enabled. Make sure the .NET SDK is installed and is on the path.
do you know what version sdk you have?
Cause maybe your .net just is corrupted or you have to download it manually (i'm not sure which version vscode use tho)
Was vscode open while you installed .net?
Linear interpolation.
thx
Lerp for short.
thx idk why i didn't think of that
are you trying to use an existing dotnet installation? if so, try installing from vscode instead, with the .net install tool extension
command palette > .NET install tool: install .NET
and then restart vscode when it's done (check the output tab)
I'd assume that you need to add the path to env variables, but I've no clue how to do it on Linux.
at first i didnt even had dotnet, vscode refused to install it, so i installed it manually through the ms website
that didnt work so i tried through terminal (the flatpak iirc)
still nothing
no idea either
also, probably unrelated, but unity crashed my entire system by eating all of my RAM and swap memory
idk how to profile that
and where do I use that?
found it
Error : (DotnetAcquisitionFinalError)
An error occurred while installing .NET: Automated installation for the distro Freedesktop SDK is not yet supported. Please install the .NET SDK manually:
:/
okay despite the errors, thee vscode now sees my functions properly
I'm currently making an undo/redo system
The problem is that whenever I undo a 'Create' command, the reference gets destroyed, and subsequent redo's cause exceptions
(if I destroy the GameObjects)
if I disable the GameObjects, garbage objects that can no longer be accessed pile up
(for example, Create Object #1 -> Undo -> Create Object #2 will cause Object #1 to be inaccessible permanently, and the object is no longer useful)
Can someone point me in the right direction?
Where are those objects hooked into, so they are still referenced? If you create it and set it as reference somewhere, you also ahve to remove that too.
I somehow fixed it by creating a List<Object> that holds disabled (instead of destroying so that their references aren't destroyed) objects whose creation commands have been undone, and whenever a new command is performed (instead of undoing/redoing), destroying all the objects in the list (so they don't pile up) and clearing it
Again, if you undo the creation of the object you should also clear up all references. Otherwise, if you start adding up all objects created for lifetime, you might run into a big pile of unused but still present objects. You rather should save the command in the redo instead of the object itself.
Otherwise, if you start adding up all objects created for lifetime, you might run into a big pile of unused but still present objects
i mentioned how i resolved this issue in the second part of the sentence
so if you create an object A, undo and then create another object B, object A (disabled) gets destroyed?
yes
Ah, got it. I still got a bad feeling about your issue that there are still references present when undoing. If you create object A, undo, undo, redo, redo. What happens there? Because on the second undo for example, the object A gets destroyed but redoing two times should bring it back, right?
no (as in object A doesn't get destroyed)
as i mentioned, object A only gets destroyed when performing a new command
undoing/redoing preserves the whole stack, and the objects are still present
Ahh, yeh, true. the new is the important word. Sounds like a solid workaround.
Just keep in mind, whenever you allow to destroy objects apart from undo/redo queues, how you would clear up those references. But if you only stick to the undo redo list, you should be fine
yeah, i'm planning on only destroying objects in the aforementioned case
Is changing agent.avoidancePriority GC heavy?
It's just an int, so probably not allocating at all..? What makes you ask that in the first place?
because the method with it shows 0.5KB at profiler
there might be other things causing that tho but it's my first suspect
That's a weird suspect to pick.
You can use profiler markers to isolate separate lines/blocks of code in a method
Or just share your code
Elo, I'm working on a game similar to Prison Architect but focused around SCPs, entity interactions and events. I've gotten a rough version of the camera to work using the PlayMaker plugin, but am unsure on how to get the actual building/tile placement to work. It will be a 3D game, and I will need the tile/building system to work like this:
I will need the tiles to have multiple states and layers for different types of object on each tile, for example: all on 1 tile would be: The ground ( layer 1 ), Object ( layer 2 ) Entity/Character ( layer 3 ), utility/wiring layer ( invisible, but allows systems to function ).
I will need it so that I can easily have hundreds - thousands of tiles at once while remaining performant.
Entities will need to be able to navigate around and interact with tiles, such as walls and doors, and respond to tile states, such as if a tile is on fire.
I have tried to do this and have looked at many tutorials, and I couldn't find anything similar to what I need, so I was hoping I could ask for help here, and preferably get continued assistance throughout development of my project from someone, who preferably knows C# well. If you have any idea on how to do this, or are willing to help me make this, please let me know, but if not all good, thank you for your time and reading this :)
I doubt anyone would be willing to provide "continuous assistance", but you could start a thread in #1390346827005431951 and update it over time.
As for the implementation itself, the important thing is to start and get something working. Even if it's not performant.
That being said, with the scale you described, might want to think of ECS right away.
How to isolate blocks of code in a method for profiling? Trying to read docs through, can't find so far
As I said, profiler markers.
is there a way to connect a object scene into a prefab script?
before I do that I would ask if a delegate assignment can generate many garbage
i imagine it'd internally basically be an array-backed list of delegates, so would just potentially be that array in that case
imo just stop guessing and go check so you can just know
It can generate some, yes. Not a lot.
I got 128 bytes and I am curious what did it
Well, we can't really help you with that without seeing the code.
it's just a bit confusing
private enum VelocityStatus { SpeedingUp, Stopped, SlowingDown };
private VelocityStatus _velocity_status = VelocityStatus.Stopped;
private VelocityStatus velocity_status
{
get
{
return _velocity_status;
}
set
{
if (value == VelocityStatus.Stopped)//so transition be more smooth
{
if (is_halting_walk_anim_on_stopping) animator.SetFloat("speedKoeff", 0);
}
else
{
animator.SetFloat("speedKoeff", max_speed * move_anim_speed_koeff);
}
_velocity_status = value;
}
}
protected virtual void AngerEnter()
{
velocity_status = VelocityStatus.Stopped;
agent.avoidancePriority = standing_agent_priority;
agent.ResetPath();
spotting_anger_timer = spotting_anger_cd;
is_spotting_anger_allowed_now = false;
doState = AngerLoop;
}
Is that animator.SetFloat()? 🤔
doState is a void delegate yada yada
this one AngerEnter call gave 128B garbage
Probably the doState assignment.
This likely creates an objects on the heap containing the state of the function to call.
Might be wrong. But it should be easy to test.
I suppose SetFloat could allocate if you use strings instead of integer parameter IDs?
Hey everyone. I am currently building a game using a bootloader scene that adds/removes scenes additively. In my current situation I am loading a scene, and the scene has objects that registering some scripts to my service manager. I then unload the scene later on. Then I get an error when I try to load the scene again. My service controller throws an error because the script is already registered. I can easily just do a check if it exists already and just not register it again. I can also just make it a rule to not unload scenes if I am going to use them (maybe just disable all elements) but this seems like I might forget/not the safest approach. Or I can try to do some kind of unloading system with my service manager when a scene unloads (which I'm guessing is going to be tricky). Any thoughts/ideas?
Why not unregistered your script on destroy/disable?
So, I was guessing this was the best approach but I'm guessing that would require me tracking which scripts are loaded by which scenes. I was just not loving the added complexity of that.
Why do you need to track that?
So my current scene loads three scripts for example, when I unload the scene how am I going to know what scripts in the service manager to remove
By reference. Manager.Unregister(this).
Ahh...so add OnDestroy to the scripts and have it unregister in them. Then, when the scene gets unloaded the unregister will automatically run?
Yep
Haha...yeah...that is much easier. Ok, thanks so much.
yep it was the delegate assigment
now I wonder if it's an issue or not
each NPC change it's current state fairly often
ok I got questions
delegate allocate 1.2 KB?
oh right it was for 10 mobs at the same time
well I prolly going to learn to make delegates alloc free
Hey, is this the correct Chanel for asking about performance?
why is this happenin that refrence script thingy is cuz i removed the script cuz i figured i want the camera to be fixed instead of following day2 in unity already having me crash out
The camera in itself doesn't move, no?
i mean why is it zoomin out like that?
Maybe your environment falling
From the camera it looks like it's not moving
Does the canvas have rigidbody or something?
remove it
Why does the environment need the rigidbody?
oh damn its fixed ty guys i look up to both of you now 😭
i guess accidentally or he thought he needs rigidbody for collisions
Could anyone clarify why the unity docs say that for a collider to trigger, one of the two gameobjects needs a rigidbody component? I've been triggering colliders with nothing but a charactercontroller till now
yeee
i thought it need for collision and stuff
Character controller also counts
Rigidbodys and character controllers
aightie thanks
triggering colliders or trigger colliders
Basically rigidbodies and ccs are subscribing to the physics system. colliders are just "static" shapes in that case. Rigidbodies will turn them into "living" objects and part of the physics world.
wouldn't usage like that get interned and not do have extra allocs (besides the first)/GC pressure
(or is my understanding of interning wrong)
Anyone capable of reading this? Yesterday 150 fps on average but after changing some very very small code, nothing performance heavy, and now its 120 - 30 fps spikes
I kinda forgot the interface but enable deep profiling open call stacks select the spike on the graph sort by time and unwrap functions figuring out what is the worst performance killer
also look for GC, idk where exactly to see how it affects peformance but too much of garbage is always bad for it
Okey I'll try, thx
I think learning french is easier at this point...
Ill look for a good yt vid on how to read this
@thick root no off-topic images, please
Is there any official Chanel for performance?
#1390346827005431951 has optimization tag
Okey I'll note it down for future
Btw for anyone curious about my fps issue, when laptops are not plugged in they enter into energy saving mode and loose 70fps of your build.
should i use animator.setbool or animator.Play for changing animations
both work. Depends how you set up your state machine and what you're trying to do.
Best practice is to control the state machine with parameters and transitions (SetBool, SetInt, etc..)
But you can build your own state machine in code and use Play if you want.
my animations dont play sometimes
hi I'm trying to add a mechanic to my game that requires two keys to function properly, was wondering if the best practice here would be to just make two keybinds for each letter and only check for one at a time or if it would be better to just rebind one singular input action every pendulum swing
rebind one singular input action every pendulum swing
that would be a fragile/stateful system
using 2 binds would probably make the most sense

it'd also mean you would have to make your own rebinding system if you wanted to let players rebind keys.
or to take advantage of the input system's rebinding, you could have 2 separate actions that you pull bindings from, and oh look it's the first option but with an unnecessary, complex intermediate step
Can anyone guess why this is crashing when Attack() is called?
NullReferenceException: Object reference not set to an instance of an object
{
HandleHighlight();
if (GameController.Instance.State.currentPhase == GamePhase.Battle)
{
Debug.Log("clicked");
BattleManager.Instance.Attack(eventData.pointerPress);
}
if (GameController.Instance.State.currentPhase == GamePhase.Main1 || GameController.Instance.State.currentPhase == GamePhase.Main2)
{
RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, eventData.position, eventData.pressEventCamera, out dragOffset);
}
}
public class BattleManager : MonoBehaviour
{
public static BattleManager Instance;
public GameObject attacker;
public GameObject defender;
public void Attack(GameObject target)
{
Debug.Log("called");
//if (attacker == null) attacker = target;
//else if (defender == null) attacker = target;
}
}```
the stacktrace can tell you which line is the culprit
seems like it's BattleManager.Instance that's null
whats the stacktrace?
it traces where the error came from, including the specific line
click on the error log in the console and it'll show the stacktrace under the error message
NullReferenceException: Object reference not set to an instance of an object
DraggableCard.OnPointerDown (UnityEngine.EventSystems.PointerEventData eventData) (at Assets/Scripts/DraggableCard.cs:52)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerDownHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at ./Library/PackageCache/com.unity.ugui@52e65280e89e/Runtime/UGUI/EventSystem/ExecuteEvents.cs:43)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at ./Library/PackageCache/com.unity.ugui@52e65280e89e/Runtime/UGUI/EventSystem/ExecuteEvents.cs:272)
UnityEngine.EventSystems.EventSystem:Update() (at ./Library/PackageCache/com.unity.ugui@52e65280e89e/Runtime/UGUI/EventSystem/EventSystem.cs:514)
right, so Attack isn't even being called
the top line is OnPointerDown, that means the error happened in that function
the :52 means line 52, so go check what line 52 is, see what could be null on that line
ah found the issue, i didnt have an awake function to set the instance
thank you!
actually, im having the seperate issue where the target isnt being properly passed through attack()
i'm trying to get the player position for the enemy attack direction but it's a bit off mark , is there a way to manually add or substract to a axis of the vector?
you can creat a new Vector3 and pass in the x y z
tkx
would be interesting to find out where the offset comes from
Add or subtract a vector with a value in only that axis.
{
float t = 0f;
Color c = fadeImage.color;
while (t < fadeDuration)
{
t += Time.deltaTime;
c.a = Mathf.Lerp(startAlpha, endAlpha, t / fadeDuration);
fadeImage.color = c;
yield return null;
}
c.a = endAlpha;
fadeImage.color = c;
}
public void FadeOut()
{
StartCoroutine(FadeCoroutine(0f, 1f));
}```
anyone know why this works in editor but not in build?? this has been annoying me for the past hour or so
add some relevant logs to find out what specifically is happening in the build
!code 👇 also see how to correctly post 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/
📃 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.
alright thanks