#💻┃code-beginner
1 messages · Page 747 of 1
do it.. (use localRotation to compensate for children)
What do you mean by that?
transform.rotation is global..
Oh like that. Yeah i'm using localPosition already
and localRotation?
still need more context
.. Huh lol
u havent said what the actual problem was
you're basically asking for pivot logic, right?
(set initial position + rotation per object)
Probably to just position it by hand in scene view, save the values?
just.. make the origin an pivot in your prefab or whatever, so you can just parent that and not have to worry about it at all
sooooo pivot logic
Okay so, the invisible child game object idea
no, as a parent.
Oh you mean, the item has an empty parent that's adjusted
Essentially changing the pivot point / origin
Rather than "applying some offset" after equip to player hand
imagine you have, let's say the hand, in a neutral position around the prefab's origin
you would then position your meshes/sprites/whatever based on that origin, which is based on the neutral hand position
and that positioning can be done with child objects if necessary (if you can't set the pivot for meshes or something. idk how 3d works)
Thanks! I might try that if just "manually place it nicely & record the values" takes too long
this is manually place it nicely and then let unity record the values
[SerializeField] Quaternion is not fun ... There's only 3 numbers but it's not euler angles
yeah like if you change the X value the other 2 start changing ...
That kind of thing. It's like computed on the spot, so weird
I assume so, since they're hiding the 4th
ye
Idk why it's like that, it's like misleading to look like it's euler angles
Wait I could just have the entire Transform serialized maybe?
ANyway. Thanks for the help
it does show 4 values for me
no that would serialize a reference
a Transform is pos/rot/scale but also parent and children
6.0 .58f2
im on 2022, so might be something that changed in 6
ah. yeah lol Bruh
i mean you shouldn't edit quaternion internals anyways, so if you want to serialize a rotation it should probably be in eulerangles anyways
yeah i only avoided that route since it showed up with 3 values 🤷♂️ misleading
gonna try "Copy > Position" and rotation see where i get with that
ok imma just be blunt
why are you asking here if you aren't gonna take our advice lmao
there's a reason why "pivot" has its own name
it's useful
knowledge
the alternate routes you're suggesting are just, more work
I'm not ecstatic about having invisible child game objects either
how's that useful if you're just going to discard it all
cool, then don't do it because it's only giving you more work 😆
maybe next project or next version I'll need it
maybe I'll need it in 10 minutes after i realize the way im trying is too much hassle
or you could actually apply the knowledge now and see a nice, clean workflow
Your explanation is not that clear
yeah so you're going to trial & error anyways, what's the point of us taking time to give advice then 😂
then ask for clarification
i cannot read your mind
Just came to say, "don't mess with an actual Quaternion value" . . .
I don't really understand what to do.
create a gameobject
put your "item" as a child
So my item, I give it a parent empty game object, and then I can freely adjust the item gameobject, effectively changing the "pivot"
Is that it?
Okay thanks. I'll give it a shot like i said.
I'm not ecstatic about that method because it changes the structure
Now I may have to do FindComponentInChildren or whatever, or go up and down the hierarchy manually
Thanks so much, I appreciate your help & this is definitely a great solution. in Blender we can just change the pivot point so, this is the Unity workaround eh
for both of those, you generally just shouldn't do that and should have serialized references instead
well, for sprites, you can do that.
i'm not sure if you can for meshes or other 3d stuff, since i don't work with that
you might be able to, try googling around.
yeah you can of course
in Blender, but not in Unity. hence the "parent game object" hack 🫡
I wish they'd leave the Unity AI stuff alone and give us better Blender integration
i'm talking about changing it in unity...
You can do that?
I thought it's Blender only, just like applying scale or rotation etc
Or you're referring to the "empty parent game object" hack that lets us fake the pivot point edit
no, i'm saying i don't know if you can
yeah i dont think you can. same way you can't "apply" scale or rotation, once it's an FBX that's all baked
a quick google seems to suggest that the answer is not easily, but the forum post i checked was also slightly old
apparently someone made an editor script to do so
That's wild. I wonder how that's even possible
It must be very low-level, like C++ itself or. Idk how you'd gain access to that internal FBX data
low-level, like C++ itself
that has nothing to do with it lol
it's all just data in the file
any programming language can modify files
I meant that i doubt the Scripting API has anything built in for that
or maybe that editor script isn't doing that, and is instead applying something after-the-fact, but it still doesn't really matter
if it didn't, then it wouldn't be possible
no, not how stuff works
Ok bro
for perf, maybe, sure
that doesn't affect what stuff is available
Good to hear, so then?
maybe you get access to public methods without c# bindings for whatever reason, but i doubt there's a ton of those
you can modify the mesh pivot in blender
you can use the editor script to modify it in unity
you can use a parent gameobject to make an artificial pivot in unity
do u know anything about getting more data from a Gamepad 🥹
my controller has Motion Controls (can see them just fine in Dolphin emulator)
but nothing in Unity's input debugger or elsewhere
I found some stuff online, I think it's actually not that hard to do. But I can't find anywhere how to see all available data of the Gamepad
gyroX = ds4.GetChildControl<ButtonControl>("gyro X 13");
This line of code works for my Gamepad, but other ones like "gyro Y 14" throw an error. I just need the internal labels of the Gamepad
please don't ping specific people for new questions
a new question would just be a new convo
perhaps ask in #🖱️┃input-system
Mb thought it was chill like that. Sorry
me answering your previous question doesn't guarantee i can help with a different, unrelated question, so it doesn't really make sense to ping me for that
they displaced every vertex
https://web.archive.org/web/20140208164731/http://solvethesystem.wordpress.com/setpivot
soo.. i just ran into using static ... ; thats pretty neat..
using static Spawn.Helper; FunctionA();```
instead of `Spawn.Helper.FunctionA();` or even
```cs
using Spawn; Helper.FunctionA();```
not sure i know how it works exactly.. are there any "gotchas" with this approach? or should it even be done vs the normal approach of using namespace and coding `Class.Function`?
it basically just adds that class as a namespace/scope (java also has this with import static)
imo they are more handy when you got some type of nested type
as usual with including namespaces, the main concern would probably be naming conflicts
cool, i like it
using static to get SomeClass.SomeMethod -> write a new CurrentClass.SomeMethod -> stuff breaks because the old calls now point to a different method
Think you might've been right, seeming like there's no easier method than the empty parent object pivot point hack 🥲
can someone help me with my game I just finsihed doing my animation transitions from idle to walking to running etc and the way i triger them with will bool paramiters and i want a player controller that allows me to link those animation so when i walk the walking animation plays etc
what are you asking here ?
youre asking for a locomotion set up?
theres a thousand youtube videos showing how to do it, its pretty simple
i am asing for a way to link my animations to a movemnt controler also i ddon't know what controler to use
🤤 lol
usually a blend tree can make it easier so you can link the player movement speed to a float you control blend tree with for Idle, Move Run
i personally used this playlist to get started with animations
https://youtube.com/playlist?list=PLwyUzJb_FNeTQwyGujWRLqnfKpV-cj-eO&si=SCp507E23sOEx_X5
this sounds like giberish expain in dumb dumb terms please
is that chromatic abberation on your editors text 🧐
you can use this and link the player move speed in the code to control which animation plays
something like animator.SetFloat("MoveSpeed", character.MoveSpeed)
thanks
Better yet, find a video called Escaping Unity Animator Hell …
You can switch animations in code with CrossFadeInFixedTime. No more spiderman web
ehh if you have few animations its fine
i mean you could just use print at that point lol
lol true
but yeah if you start creating a huge nest you should probably do it programmatically
Any game worth making has more than a few animations
flappy bird
just do everything procedurally 🤑
games like SupertHot etc.. very succesful game, barely any animation
yeah no i don't get the spiderweb thing
ill probably get it at some point, but that just hasn't happened for me
I think a game with most animation was in a GDC it was Firewatch and they also used animator, albeit very clever and "organized"
this is kinda facepalm moment tho.. lol
ive made my own static debug classes and always tried to do clever stuff like
call the class D and then the functions would be called bug() or ebug()
so i could do D.ebug.Log("Custom stuff");
and now im freaking realizing i coulda just done something easier w/ this using static declaration 😅 gotta laugh at meself
idk why people dislike the animator so much
Idk, combined with a state machine and some AnimationCurves, i'm fully in love with CrossFadeInFixedTime
so does UI eccentric games like Papers Please
masters of the tween
i guess coming from unreal being to do anything in a blueprint esque system is more ideal for me
Oh yeah i hate blueprints. prefer to do things in code
blueprints suck though
everyone has their preferred cup of tea
funny i find it the other way around lol
altough when i was working on this i absouletely had to use animancer (i think) because there was about 30 different transitions at play https://cdn.discordapp.com/attachments/1390716509638098995/1400201207318057082/drifterclipawesome_1.mp4?ex=68ec03fe&is=68eab27e&hm=97fb874624b6d2e7431619fe442ecc6f9126bf14d07fd467da93d19a0334a290&
audience cheer
i dont mind doing things in code most of the time but if i get to use blueprints oh boy im gonna use em
theres visual scripting for unity ykno
ahh ok
i get my daily taste of blueprints with the animator lol
😈 lol
btw, this is the code channel
this convo was about animation from the start though
a question about animation
There's no off-topic here. Read #📖┃code-of-conduct
hopefully it's answered by now
so.. this channel isn't the right place for it
guess you can tell that to the original person who asked the question lmao
ya i think so. I think i understand now
true games like that are doing really cool tweens.
"InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
UnityEngine.Internal.InputUnsafeUtility.GetKeyString (System.String name) (at <203eea2e137a4ed1b7efeba5ef6d9400>:0)
UnityEngine.Input.GetKey (System.String name) (at <203eea2e137a4ed1b7efeba5ef6d9400>:0)
AnimationStateController.Update () (at Assets/AnimationStateController.cs:16)"
when trying to do
"if (Input.GetKey("w"))
{
animator.SetBool("walking", true);
}"
in the void update function
!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.
also read the message
ok
!input
To set Active Input Handling, go to:
Project Settings > Player > Active Input Handling
• Input Manager (Old): Use the original Input settings.
• Input System Package (New): Uses the new input system package.
• Both: Use both systems.
oh there is command for that? niceee
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.SceneManagement;
public class baseHealth : MonoBehaviour
{
public int totalHealthValue;
public int chestHealthValue;
public int houseHealthValue;
public int waterfallHealthValue;
public TMP_Text totalHealthText;
public TMP_Text chestHealthText;
public TMP_Text houseHealthText;
public TMP_Text waterfallHealthText;
public GameObject gameOverScreen;
void Start()
{
totalHealthValue = 750;
chestHealthValue = 250;
houseHealthValue = 250;
waterfallHealthValue = 250;
}
void GameOver()
{
SceneManager.LoadScene(2);
}
void Update()
{
totalHealthValue = chestHealthValue + houseHealthValue + waterfallHealthValue;
totalHealthText.text = totalHealthValue.ToString();
chestHealthText.text = chestHealthValue.ToString() + "/250";
houseHealthText.text = houseHealthValue.ToString() + "/250";
waterfallHealthText.text = waterfallHealthValue.ToString() + "/250";
if (chestHealthValue <= 0)
{
chestHealthValue = 0;
}
if (houseHealthValue <= 0)
{
houseHealthValue = 0;
}
if (waterfallHealthValue <= 0)
{
waterfallHealthValue = 0;
}
if (totalHealthValue <= 0)
{
GameOver();
}
}
}```
why do the enemies still go towards the destroyed bases :/
pls assist me
uhh where is project setting sorry
thanks'
use links for large code instead a wall of text
things you can easily google btw
my bad
make it a habit to research
links?
mhm see #💻┃code-beginner message
gonna need some context
we aren't psychic
ill remember that @rich adder
or just don't make it difficult for people to help you now?
this is literally a pain in the ass to look on mobile
ok ok
telltale character ass response
let me reformat ts
fym, this is a pain in the ass to look at on pc too
we are the ones who are willing to help but we need context
so i was gonna provide context when someone responded
yeah no, not how this works
youre allowed to do it right away
we beg you, just provide all the info right away
you should open your question with everything ready right away
didn't realize there were a lot of people who wanna help
so we don't have to play this game of telephone
ok
if they have to play detective, they will most likely walk away or not respond
give me a min rq
and this is why you should provide all the info straight up
do i just give the blazebin link to my thing
yeah the “anyone can help me?” is like a daily thing I see
mb bro 😔
no ur good ive done it before too
there's always a first, we don't judge
but if it keeps happening, we'll start judging 👁️ 👁️
it can be tough waiting on replies so. we get it
yeah, along with context on what exactly it should do and how it's going wrong
to be fair, it does show a lot of character in effectively not wanting to immediately dump your issues on everyone without seeing if anyone wants to help first but its also unfortunate that its simply not the way discord or most online forums work
and i dont mean unfortunate in a bad way
its very efficient lol
it is definitely unfortunate that the efficient ideal and the presumed moral ideal don't align
but imo once you get used to the efficient ideal, it's so hard to go back to the moral ideal lmao
Are you checking if the base is destroyed? before the enemy switches to following it
https://paste.mod.gg/basic/viewer/zusqvyuyuaqb/1
basically its a 2D tower defense game, and my enemy units switch directions to go towards different bases. It uses a tilemap system, so there is a tile with the tag "crossroad" that tells the enemies which way to go. Normally, it makes them go in a random direction (left, down, or right), but it's supposed to check if a base is destroyed and make it exclude that direction from the options. I don't know why it isn't working though.
A tool for sharing your source code with the world!
You provide context at the beginning. Without it, no one will/can help becasue they dont have enough info . . .
specifically in the ChangeDirection method
i have an itch.io page for it but it isn't fully updated so lmk if you want me to update it so you can see it
i probably just messed up a math check thing :/
i think your changedirection() is failing because its overlapping random logic without actually excluding destroyed bases, so enemies can still pick the invalid directions without choosing from the active ones
oh
im not sure though i could be wrong which i frequently am
so uh wait and see what the others say
ok looking at it again
youre going to have to build a list of valid directions first and then randomly pick from those valid options
alright
Anyone has experience with ink dialogue ?
I think i last looked at ink like 7+ years ago so probably no
holy state machine moment
hello
i am very new in this unity game dev platform
doing my first project and i stuck at a point of animation
can anyone help me a bit
please
@merry thunder send the details we gotchu
so you ignored the bot message and just went ahead of doing the same thing by crossposting
i did't ignore it
i was trying it from yesterday night but its not working
i dont want to be rude here but i do notice how bot messages seem to be some sort of blindspot for a lot of people
not exclusively to this server
and i have no clue what causes it
yeah people with reading comprehension issue and attention span of an ant
i tried to add a animated character at the last panel when the game ends and shows the winner/loser
the animation is working showing in animator and animation panel but the animation is not visible in the panel but other than that is visible
is this a code question or what, I don't even understand where the question is
Is it a layer priority problem ? Maybe it is behind a panel that hides it ?
i myself is not sure where did it go wrong
Who know how should i make include of my ink dialogue file ? (I mean) for a small projet is fine but if we have a lot of dialogue should i juste make some independent dialogue alone and make a big included file for dialogue that need sharing info ?
We’re gonna need way more details, screenshots etc
Generally all Ink content should be in just one story that includes everything
“Playing an animation on a character” is a simple question, but this is clearly more
where can i send them like screenshot
People send pictures in here all the time
If it’s code use triple backtick or one of the pasting websites
!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 a code channel
If his problem isn’t in code we’ll go elsewhere
A tool for sharing your source code with the world!
its a mystery at this point
I made it but those include , should i juste make main story -> include all other dialogue => doing jump between dialogue from the main
If so , how should i attribute dialogue to npc ?
Yes. Except jump between dialogue by starting the story directly from knots

How should i start directly from knot ?
Because before i just drop the file ink generate from the ink file directly from the inspector
(The json)
There's a dedicated Ink server, you know. This is only tangentially related to Unity
Oh thx i will go find it then
i have added 4 codes to the blaze bin how to share it
A tool for sharing your source code with the world!
previously i was stuck at showing the player stats at the end screen
now at this
hey, is there a way to get whatever script is attached to a gameobject, regardless of the name?
for example, i would normally get a script via myObject.GetComponent<scriptName>()
but lets say i want to get whatever the first script attached to an object is, is that possible?
i think its possible i guess, by adding a script in assets then drag it to the inspector in the gameobject
use an interface to look for specific types, why any scripts? whats the usecase
(it is possible but usually there is a better way)
The quickest would probably be
...GetComponents<MonoBehaviour>()
Moni
😄
was just curious but i am assuming there's a better way
i just have a bunch of different objects that i want to all have the same bool attached to them (like a status effect basically), and i want outside forces to be able to turn the bool on and off regardless of what script its in
Thats also pretty common with just good old inheritance
I.e. everything derives from Bob. And you use overrides to change the behavior when needed
hm ok, whats a good resource for how best to take advantage of inheritance
You can create a separate script and attach it to all GameObjects that you want to have this status effect, or place the variable on a base class that other classes inherit (inheritance), or create an Interface with a bool property, then implement the bool property on a class attached to the GameObject . . .
was thinking of doing the first option, sounds the simplest
This is why understanding programming and OO concepts is useful
trying to learn programming alongside unity means you probably wont know about this stuff
The first option is nice because I would add every GameObject with this script to a runtime collection when spawned. That way, you can iterate and access all of them from one place . . .
@floral garden bro if you check the code i pasted and understand why its not working pls let me know
it's 3 am now and i can't focus on that anymore good night
if you need anything else to understand it ask me
thanks
Goodnight to you , i will check it in 2 days because i am very busy next day

you can check it also if its possible and tell me where it go wrong
I started looking but 1 big jumbo script is hard to read though
your UI should not be mixed in with your gameplay logic

Btw is it a better way to split my player stats machine or should i just put it in a file?
what is a stat machine
Fsm
hmm nope no idea
Like how unity work
How to said. Instead of doing one file where you manage everything, you split it into multiple class each manage one thing. Like idle, walk, run , death
Unity is more complex but see it as awake start update fixedupdate etc
those are not even close related to state machine
Isn’t it how it work on unity?
those events are not state machine, the closest state machine built in unity is Animator
I cant follow what you mean but its always best to have a class perform one task. You may be confused about what state machines are.
Start/Update/Awake are message functions for MonoBehaviours and thats it.
hi, i wanted to change the terrain color, and the editor also got orange, and its working with every color, what the hell is that? 😭
not a code question #💻┃unity-talk
looks like playmode tint is on
we would have known if provided in your message
anyway setting a materials main colour wont do much unless the shader on the material uses a color to do something.
Well, i may miss some vocabulary haha
https://docs.unity3d.com/6000.2/Documentation/Manual/execution-order.html
but from it i must mixed fsm with message
you're better off making a terrain shader and do terrain properly
unity terrain finally leds you make shadergraph terrain shaders
I still have no idea what you mean by fsm but all this diagram tells you is the order in which things get called during a single frame
Yes and i mixed it with the fsm xd
these are just functions called at specific times
A finite-state machine (FSM) or finite-state automaton (FSA, plural: automata), finite automaton, or simply a state machine, is a mathematical model of computation. It is an abstract machine that can be in exactly one of a finite number of states at any given time. The FSM can change from one state to another in response to some inputs; the chan...
so is there any way to check where its not working or whats wrong ?
Just a state you can change when you need. Other than using a lot of If or switch
a fsm can be done with a simple enum too.. the concept of it is basic
dw i know what they are 😆
Yes
With enum is some called fake fsm (my teacher said)
fake fsm lol
if you're in a state you're in a state, sometimes you don't care about OnEnterState events and such
if you provided better direction then maybe but i dont fancy reading that all to understand myself
Like i said, one jumbo class with too many things mixed together is hard to understand and parse
yes thats true
Soo many teachers have such outdated views its worrying
Well, it will overload your class not ?
idk what you mean tbh
you dont always have to abstract everything
..some of the biggest games have been made with simple switch and enum
It is only a method 
not sure what you mean "it is only a method"
To replace a big switch or if else
depends on the game.. you can also split it
switch can handle lots of cases with ease though, generally speaking is preferable over chain of if else
ik, I get what you mean though...
I just meant sometimes its easier to have that than a complex abstraction for a FSM.. so call it "fake fsm" is kinda strange lol
Oh i see this what the teacher answer me 
and in games we often prefer speed over some over engineered solution with needless layers
Oh?
just mention something like Vice City / Gta3
I have done some game but still beginner

the quickest example that came to mind cause i looked at their source code A LOT
"fake fsm" all over the place, very succesful product . Straight to the point code
Is it in C ++ or c# ? Or both
c++
https://github.com/Hezkore/hez-gta-re3/blob/master/src/peds/PedAI.cpp#L79
one of many examples of switch
O-o?! Damn
A lot of case
Maybe i should read some unity game source code
(If there are)
Not much legally exists for comparable projects to gta
Not gta but other type of game so i can learn from them
hence why i said comparable
if you're lucky you find the source codes people do reverse engineer
the original repo got DMCA'd though so someone else reposted
most people don't reverse engineer unity games because usually they don't have to
Nah i prefer source code people want share other than stealing
You can peek for curiosity / learning
something like dotPeek works
but yeah I cannot say much more cause I'll get kicked
theres no real point to even going through source code unless you're interested in a very specific feature. code in your singleplayer games does not need to be complex
I'm going absolutely insane
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.Tilemaps;
public class WorldManager : Utilities.Singleton<WorldManager>
{
[SerializeField] private List<GameObject> pathObjects;
[SerializeField] private Tilemap tilemap;
List<Path> paths;
private List<Path> pathsWithEnemies;
//Initialize the Direction array array
void Start()
{
InitPaths();
}
void Update()
{
}
void AnchorPoints()
{
}
void GetDirectionFromPath(int pathID, int currentIndex)
{
//return paths[pathID].tileList
}
void InitPaths()
{
int x = 0;
foreach (GameObject pathObject in pathObjects)
{
paths[x].GeneratePath(pathObject, tilemap);//
x++;
}
}
void UpdateEnemiesOnPath(Path path)
{
}
}
for some reason, adding a serializeField to the list here makes it so unity starts having a spasm, failing to display things in the inspector, and giving like 10 different errors
I have absolutely no clue why it's doing this? I'd swear I used this method already in another project to add elements to a list from the editor
(referring to the serializeField in pathObjects)
!code 📃** Large Code Blocks**
📃 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.
Unity 6?
Maybe it can’t be serialized
if you're on the latest its "normal" its a known bug
yeah I'm on 6 due to decisions that I did not get a say in
then how do I make a list of objects that I can assign from the editor without unity having a seizure?
GameObject is definitely serializable...
revert back to the version without the bug
I'm on 6000.0.58f2 specifically
Yeah stupid answer as if it can’t be serialized it would be just skipped xd
maybe try 59f2 ?
always keep a repo commit before doing these upgrades
the previous version of the project was also unity 6, but apparently it had a security vulnerability and we were forced to upgrade
yes serializing is mainly only when it writes to the file
yeah but only relative to when you actually need to release it, by then unity will have already patched it
besides you can use their patching tool for binaries and work fine with the editor with "security issue"
I'm downloading 59f2 to check if it's still there
It will block the issue ?
how would this work in the first place, List<Path> paths; is not initialized so paths[x] is always going to fail
unless you're referring to unity editor errors, those you should make a bug report for
Or bypass
the tool will patch the UnityEngine.dll specifically
Oh i see
so really changing editor in a haste is a panic move
the idea is having a list that you add things to on the editor, but when adding serializefield to pathObjects the editor itself starts giving errors and fails to display inspector text even
(The rest will be worked out later for now I just need this damn list to work)
the displaying editor text error is known at least. I remember someone mentioning a fix with fonts but i never looked deep into that.
either way your current code would still always error
paths is not initialized
oh yeah you wil def catch a NRE for Path list
Nre?
the display thing hopefuly is fixed in 59f2
yeah I know that, I just haven't gotten to it cause I need to get the list going to do anything anyway
Null Reference Exception
a list must be initialized otherwise it will throw when try to access
public / serializefield in unity will serialize them in inspector so it will initialize them for you
Oh also, how is the correct syntax for initialization ?
List<gameobject> list = new() or
New List<gameobject>() ?
it's New List<gameobject>() no?
I don’t know, people always write it both side but only new() is fine
Btw Both is correct
unnecessary repetitions 😛
That xhat i thought 😩
but also makes your code compatible with older C# versions
Ahhh
your IDE probably has a few messages telling you that it can be simplified into just new()
unless you use var everywhere
Yes
For me
If you write an asset or something and someone is running older unity version with c# 8 or less it wont be happy
My teacher said : if you use var , use it only if necessary xd
(you are allowed to use var? at all?)
not as fields / props / return values, but as local vars
Sometime not but the compilator can manage find the correct
Like var value = 1
use var is good when you know the type is explicit enough
Var = int or size_t or other depend what you are giving
if its vague and you only know through IDE it could be a problem
var something = 4; // we know for sure its an int or at least a number
var somethingElse = MyUnknownFunction() ; // wth is this?
Reel
but good naming can also fix the second example
CalculateHealth() probably returns a number . etc
Moral : var is good but use it in parcimonie
Well clearly it's a delegate of... some kind 
clearly some kinda code at least


Trying to logically think about how to develop a simple health system, any feedback on what I should probably not do?
A separate script that can be attached to any GameObject entity as long as it has a dedicated Hurtbox collider set as child, and give it health/damage/death interactions.
It will look for a child with the name "HurtBox" and set it to be a trigger for health decreasing.
Within it there will be the damage data of everything in the game listed.
It will also change the health data based on what object it's attached to.
I might separate health calculation and damage calculation into 2 different scripts once I'm more knowledgeable in the topic (since damage will have some specifics and might become complex).```
I also thought of allocating all the game damage values, types, ETC in a different file but I'm not sure how that would work.
the first idea is fine, the hurtbox thing is pretty smelly code imo
the health component should not care about any triggers / colliders
But then how would I register that the object got "Hit" and update the health accordingly?
it should have a method you can use to modify health and all that responsibility
it only cares about changing the values and keeping track, it should not care HOW it got those
make another component for trigger damages
so you can have other means of affecting health not just using triggers only
say you make a TriggerHurt component, it only cares to tell a Health if one exists, "Hey I got hurt subtract 10 hp" etc.
hmm but then wouldn't I have to make a way for the damage script to communicate directly with the health script? How would that work? I'm not sure how to make 2 scripts communicate with each other.
easy, you reference it .
if its a "DamageScript" or alike.. you already know its most likely going to be affecting some type of "health" component
you create a field of Health and assign it , if its not null you communicate to it
this way you can create other triggers or functions that talk to Health, what if you have healing potions / trigger areas and so on
tight coupling should be used sparsely, no reason health should need a triggercollider to function
Ill point out that its probably a bad idea to have specific components for "health" and "damage"
there comes a point where we have gone too specific and it makes things harder
Supposedly, if we have an object called Player and 2 scripts, script1 and script2 attached to it.
An interaction just happened with Player, but only script1 detected it.
If script1 detected something that happened to Player, but it needs to report it to script2, how would he do that in Unity?
I suppose more of opion thing, have always worked with sepearated Health and HurtTriggers and alike for ages , been working fine
why should my health care about triggers and physics?
You find the specific Player at runtime in the Hurt trigger and check if got the Health component, you're only modified its health components
you dont even need to check Player usually anyway, like
void OnTriggerEnter(Collider other){
if(other.TryGetComponent(out Health health))
health.Remove(10);```
To some extent I get what you mean, but at the same time I want to have some degree of specificity in that part because the thing I plan to make will handle damage as many different things, it will probably get long and complex and the least things in my way the better. I don't plan to make specific scripts to things that don't need attention.
These seem like things that shouldnt be related anyway. Some object that can "take damage" can do that via some interface or common type. Then whatever you want can use this generalisation
I just read this and imagined 1 tiny ass monobehaviour with 1 float/int for health and thats it. That would be kinda silly.
I tried interface for IHealth but end up always having to implement the same crap for over many MBs and makes no sense than 1 component for health
component?
okay upgrading to 59f fixed it what a headache 
oh nah mine has also UnityEvent and Action for ; OnHealthModified, OnHealthDepleted etc.
this way i can do other things in other scripts that care about health
good to know that version is the fix..
they should've done a proper check before releasing 58f2 in such a haste
But then these other objects will closely depend on this script and then we think "why did we separate this in the first place?"
Abstractions should exist for a good reason.
thats true in some cases, It always comes down to the same stuff anyway 
its possible they just didnt know. some issues dont appear on every device. They couldnt recreate an issue i reported (someone else here asked about it) about weirdness when serializing a char
I know but odd honestly but feels like lately the QA has gone way down
The objective problems with Unity we get in here have significantly raised 6.2+
yea fair, i did have issues very quickly in 6.2.1. An int going to large values crashed my editor lol
i mean i accidentally kept multiplying the value with itself but still, you'd expect it to not crash
:tinfoilhat moment but the big push for AI "enabled" editors is the same reason microsoft is getting rid of local accounts for w11. Who knows what more tracking they want to do while you develop for their training
the tag should read "Supported but Broken"
"Recommended" misleading newcomers to the AI enabled bs by default
Nobody forces you to use 1 unity, 2 ai
I haven't once used UnityAI and told them as much myself, I don't plan on doing. But I understand how it may be helpful to others. Unity have just had potential security issues highlighted so that I'd hope.. is their main concern
If you work for a studio that uses Unity you are forced to use Unity
If you are building for certain platforms as an indie you are practically forced to used Unity
Unity has a dominating presence in the Industry.
2, As a developer we can choose not to use the AI features but the focus on these AI features is time, budget and effort not being put into other areas
Godot
Unity
Unreal engine
RpgMaker
And they do have multiple teams focusing on multiple projects within unity, pretty standard industry practice.
For 3D (and most genres) RPGMaker is completely unviable
There are many reasons why Godot and Unreal are either flatout unviable or would cost too much time to be viable
And some are getting way more love than others
At the moment perhaps, but security is a big issue at the moment so I'd rather unity focus on that than minor annoying bugs such as their (already reported) GUI bug for the editor. Security over visuals any day.
As for AI.. hundreds of companies are focusing on it as it's 'Flavour of the month' meaning it will have its time and pass
The lack of quality control is highlighted in this specific instance but is not exclusive to it
While I hope it’s a flavour of a month type thing it’s still something that’s actively happening
Unity on average have 5,000 staff. This Discord alone has over 120,000 members, if every person reported an issue and they all had to be tested, even if you allocated every member of staff to testing and reporting back on bugs/problem fixing. Realistically where do you, think this may end up
Not particularly interested in engaging with such an unreasonable hypothetical
Explain why it's unreasonable? You are the one demanding they focus on QA.. yes some of it's dropped but within a year they let go of roughly 2,700 staff, reported financial losses and had some internal issues
Because it’s nowhere near the scale of 120,000 unique bug reports
Personally this is an explanation, not a justification
This discussion could go on far too long, if you wish make a thread we will discuss in that, otherwise. All I ask is be considerate of the staff already working hard to provide to us Unity engine as it is, flaws included
Why on earth would I ever want to overload a method instead of just using discernably different signatures? Are there practical uses for them?
i know this might sounds stupid but in unity uh...
is there any way to make the icons and lettering in my project bin slightly larger
Like view percent from 100-110 or something
cant find anything for it :(
wdym ? overloading is different signatures, same method name
I understand that, I didn't meant it in a literal sense.
I just don't understand how can something like that be pratical.
its convenient
different levels of control for the same function
https://docs.unity3d.com/ScriptReference/GameObject-ctor.html
(easy example)
a simple GameObject myObj = new() // i just want to spawn a gameobject
or
GameObject myObj = new("Player") // i want to spawn a gameobject with name Player
etc.
if you google the same question you asked, or even just "why overload methods c#", there are tons of resources out there. the first case you see like adding numbers with different types would make it pretty clear
You can zoom them in it changes from list format to icons etc
if you mean the font size itself not really, unless in the os
maybe check preferences
not really a code question btw
I don't understand it much, but I think my brain just needs some times to digest it.
Yeahh I'm sure, but often online articles explain things in such complex ways and I can't really talk back to them to dive further.
Here's GPT glazing the world's dumbest question.
Ya'll know whats wrong wit this code??
using System.Collections;
using UnityEngine.UI;
public class EventTriggers : MonoBehaviour
{
public GameObject dialoguePanel;
public float delay = 2.5f;
public IEnumerator ShowDialogue(float delay)
{
yield return new WaitForSeconds(delay);
dialoguePanel.SetActive(true);
yield return new WaitForSeconds(delay);
dialoguePanel.SetActive(false);
}
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
StartCoroutine(ShowDialogue(delay));
}
}
}```
🤷♂️ i dont care to see what AI says. I said google for a reason. if you have questions about what online articles say, then ask about that
you have to tell us, its your code. What do you expect this code to do, that its not currently doing
I just found it funny that it was giving such praise for a question I knew was probably not wise at all, nothing past that.
I search for both articles and ask AI assistants before iterating here not to waste people's time.
What you stated is exactly what overloading is . . .
Care to provide any context?
I left my mind-reading cap in the other room . . .
basically i was trying to make the code to activate a panel when it was touched... but it just won't show it. i have tried checking the tag, or maybe it was missing a reference but it still persist...
Did you check/test that it was touched? Is that what the trigger is for?
the ultimate gaslighting machine
yes... it detects a collision with the player on the console when i debug it using the Debug.Log
If so, place a log inside of the trigger method to check if it appears . . .
Ok, so the log was placed inside the if CompareTag statement and it appeared?
yes, it detects the player.
is this 2d or 3d
Then move to the coroutine. Place a log at the top to check that it runs . . .
wait guys... i think i figured it out, something was wrong with the collider. thanks for the help tho, appreciate it.
3d
But you said the trigger method worked, which indicates the collider is fine . . .
"when it works, don't touch it"
what does this error mean? having a hard time translating it. I notice its about my middle button input returning null but
worried i might have messed up my input system somehow
:(
the other 2 errors are about the input giving them a null reference and not being able to use it
maybe you have to call .Enable()
i really dont understand as it was working completely fine, i have videos of it working perfectly, but now it stopped once I updated my targeting requirements (in which period i "accidentally" put Control.IPlayerActions in a seperate script because i was playing around and fiddling with shit)
even more it really shouldnt be feeding a null to my target script since, as far as i understand the operand, the ? shouldnt be returning if it comes up null
whats the entire stacktrace say
Ive been told about how deep the inputsystem package goes into the project, in those exact words, so i dont know what it implies
i dont know how to pull up the entire thing, im still fairly new to unity (as per my question about font size earlier) so all i have is the console
To be honest i looked up what that was an saw a lot of console text
So the first error in your console says that you have a variable that has not been assigned, this may be a gameObject for example
The third error relates to the first
The second error relates to your input which is probably not finding the middle mouse button (Mouse Button 3)
do i have to rebuild my middlemouse input?
i mean its not that hard to just delete and do it again
to be fair i just got off work and am dead tired, very likely i typed something i dont think i shouldve
ill look over it in the morning but leaving the night with an error makes me not happy :(
Comment out the code that leaves the error, if it doesn't throw any error on recompile save and call it for the night. Prevents the editor wanting to load in safe mode next time
Well shit, already turned my pc off
Now I’ll have a fun surprise tomorrow morning
At least I know this for future issues
Safe mode is just there to let you fix a bug incase it breaks a system... Honestly it's more annoying lol, but it should be okay don't worry
runtime exceptions will not cause the editor to enter safe mode so there is no need to comment any of that code out.
also the middle error isn't directly related to your middle mouse input, it's something that is called in response to that action's performed event being invoked
presumably the first exception is the cause of the second
Yeah just thought about that too
My inputsystem can’t be playing wrong right now since literally all of my other inputs were fine, why would only the middlemouse one get hammered out of nowhere
I’ll have to look around my targeting script in the morning, should have done anything tonight as I was half asleep anyhow
Not saying it’s impossible but
how do i program manifold dual contouring? there are zero public implementation on the internet
There are quite a few open source projects on github. Just need to adapt them to C#/unity.
i cant find a single one, can you point me towards one
A simple google query: manifold dual contouring github
https://github.com/dominikwodniok/dualmc
https://github.com/proton2/Manifold-dual-contouring-Java
There's even unity:
https://github.com/Tuntenfisch/Voxels
the first one isnt MDC, the second one is built refencing broken code
third also isnd MDC
broken code..?
Beyond that, I guess your best approach is to read the paper, understand it and implement yourself.🤷♂️
yeah the java implementation references https://github.com/Lin20/isosurface which doesnt implement a solver
A project testing and comparing various algorithms for creating isosurfaces. - GitHub - Lin20/isosurface: A project testing and comparing various algorithms for creating isosurfaces.
if u read the QEF solver code it brute forces it with rotation matrices, causing it to take like 6 seconds to generate a tiny mesh
Well, you're kinda getting into niche/specialized knowledge/skill territory at this point. I doubt anyone on this server would be able to help with that. Or at least, definitely not in the beginner channel.
I'd recommend starting a tread in #1390346827005431951 and maybe someone knowledgeable in the topic could help.
is this just a rare algorithm? surely people need isosurfaces
Most people use simple marching cubes . I've never seen anyone trying to implement anything more complex.
cant do corners 🙁
anyways ill keep trying, thanks
Why not?🤔
its just a limitation of marching cubes
Pretty sure marching cubes can handle coreners just fine.
unable to do corners
nah
if u try to make marching "cubes" generate a cube, it simply cannot
Corners
thats not a cube nor are those corners
I guess what you're trying to say is 90 degree corners
yeah
Ok, but you can get pretty close to it.
not without going super high res and killing performance for what should be a 12 triangle shape
I've been stuck on this but I've been trying the (now not new) input system in unity and I have movement for my player set up but I can't figure out how to make the player move on a local scale with it since I have the camera rotate the player and would like movement to adjust with rotation and I'm starting to think that this is not a thing you can't do with the input system.
Indeed. You wouldn't be able to do it with 12 triangles. You can still get it basically unnoticeable to the naked eye without "killing performance". Just need the face to be very close the cube face.
Also, if you're only dealing with cubes, matching cubes is probably not the right algorithm at all. Something simpler that generates cube-like meshes would be enough.
i have the high res marching cubes implemented rn and the corners are very noticably buggy
Then perhaps it's just a bug in your implementation.🤷♂️
its a known limitation of the algorithm
Ok. Anyways, if you need help on that specific algorithm, I'd recommend starting a thread in #1390346827005431951
Maybe provide some more details on the issue. What's the expected behavior and what actually happens. As well as sharing some relevant code.
(i know there is a paste as value but it's still too slow)
Sa
hi
hi, this isn't a social space https://nohello.net
if you have a question, feel free to ask
i need some help with a tutorial ive been doing
Just ask your question
can i upload screenshots
I've got a question, i was researching LINQ and saw people generally advising against using it as it allocates memory and fills unity's garbage collector. but there arguments were all targeted towards using it on a per frame basis. so it it generally fine to use outside or regularly repeating logic or on start?
Not all operations create garbage and it's usually not that big of a concern. But more of a concern is impacting code readability when using it.
im creating a personal "Guidebook" because writing things down yourself and doing your own research is one of the bet ways to commit to memeory.
at the moment my topics of focus are
- Vectors, angles and Trigg
- Mathf Fundamentals
- LINQ - although i'm back to the drawing board on that one
- order of execution
- object oriented and data driven architecture
- state machines
- asynchronous programming.
any other essential topics i should research?
nailed it
!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
- ways to identify topics that keep me from going past my current limitations
Asking a online community what’s important without context will yield generic, cluttered non-helpful answers that miss your actual needs.
I can respect that, but that’s actually why I asked — while every project has its own foundation, there are still core principles that help you structure things properly from the start. Those constants are what I’m trying to get a better understanding of.
That is true but there is very little that can be said about this which isn’t overly generalized
also, your and everyone‘s opinions on that evolve with experience and you probably wouldn’t fully appreciate certain recommendations without a lot of details and lived experience that produced it.
Not saying everything needs to be reinvented, just that some things can’t really be taught by passing compact information
the key thing to figure out (imo) is: ways to collaborate effectively with others in complex projects. Everything else is a component of that ultimate skill. Code is a complication in that, which you need to minimize. So when looking at code subjects: ask yourself how the thing makes collaboration easier/harder. from that you find additional topics to explore. If it doesn’t help with collab, you can flag it as unimportant. Caveat: “getting stuff done/working” is part of collaboration, but the complexity is in “keep it working, with minimal effort, when 1000s of other things are also going on” (integration).
from what i've seen you've already got a really good grip on what u need to do 💪
and it'll evolve as u go.. so i'd just hit it
Hello!
I just started using unity, with no basis, and as you can probably guess I'm having a hard time with coding.
So I watched a yt tutorial on how to make player movements and camera look (1st person).
Everything works fine, except for the 1st person look. The camera follow rlly well my mouse movement, however it feels not smooth at all. If someone has an answer to my issue, please help me
here is my code too :
How do you call ProcessLook?
Honestly I don't really understand it, I just copied that script from youtube, I tried to understand it but it's too difficult for me, if you want I can send you the InputManager script
📃 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.
haha what did i just see
ahah I'm discovering it's taking a bit of time for my little brain
// using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class InputManager : MonoBehaviour
{
private PlayerInput playerInput;
private PlayerInput.OnFootActions onFoot;
private PlayerMotor motor;
private PlayerLook look;
// Start is called before the first frame update
void Awake()
{
playerInput = new PlayerInput();
onFoot = playerInput.OnFoot;
motor = GetComponent<PlayerMotor>();
look = GetComponent<PlayerLook>();
onFoot.Jump.performed += ctx => motor.Jump();
}
// Update is called once per frame
void FixedUpdate()
{
//tell the playermotor to move using the value from our movement action.
look.ProcessLook(onFoot.Look.ReadValue<Vector2>());
}
private void LateUpdate()
{
motor.ProcessMove(onFoot.Movement.ReadValue<Vector2>());
}
private void OnEnable()
{
onFoot.Enable();
}
private void OnDisable()
{
onFoot.Disable();
}
}
It should be Update instead of FixedUpdate
alright let me change it
oh wow it fixed it, thanks a lot. Also, do you mind explaining whats the difference between Update and FixedUpdate?
Update runs every frame, FixedUpdate runs at a fixed time interval (50 times/second by default). That's why the movement looked jagged because it moved the camera less often than the framerate
I get it, thanks a lot!
Also mouse input shouldn't be multiplied by deltatime
Oh really? How should I change it?
Well remove the part that multiplies by deltatime
Alright
wich line ?
I mean remove the part that multiplies by deltatime on both lines
and then you have to change the sensitivity down to about 1
Oh yeah I was saying "that is fast"
Yes it is so much better thanks.
Also I want to hide my cursor while playing, do you think this is a good way?
using UnityEngine;
using System.Collections;
public class CursorScript : MonoBehaviour
{
// Use this for initialization
void Start()
{
//Set Cursor to not be visible
Cursor.visible = false;
}
}```
sure
alright I'll try it, thanks again
ever heard of a singleton?
I use one for my Cursor management..
it gets kinda jank when u have more than 1 script trying to change the cursor settings
sooo i make 1 Cursor Manager.. that all scripts use to toggle the state of it
Not really, I'm completely new so I have no idea how it works
a whole singleton for hiding the cursor? overkill imo
no.. everything..
hidden, locked, confined
custom cursor tracking, offset, gfx switching all that jazz
like a CursorManager
and it keeps all the cursor mechanics in a single place
EventSystem.current.SetSelectedGameObject(object)
Hello, I just upgraded my unity project to Unity 6. Previously, When a menu opened up in my game, I would use the above line of code to select a UI element. Then the player could navigate the menu using a contorller. "EventSystem.current" seems to have been renamed to just "Event.current." I am struggling to find a way to select a ui element now though as "SetSelectedGameObject()" seems to be a thing of the past. Does anyone know how to do this in unity 6?
It was not renamed
EventSystem is correct
Hi, do any of u know how to connect a button click that leads to a ui with a camera pan? I have been trying to search for tutorials that can do both, like if I open this menu, the camera zooms in on the character. But there hasn't been anything like that
well the button click would trigger some animation or code that moves a camera of your choice
cinemachine can make things like this easier
I made a button with an on click () prompt, that sets my ui gameobject active when pressed. I also have a camera manager script for using cinemachine
I just don't know how to combine them
then you are already half way there. Enable some virtual camera and configure the anim time and mode for ANY > that camera
E.g. serialize a reference to the virtual camera and enable it when the button is pressed
oh that's good then! How can I do that? Is it through the script?
yea...
first try just enabling a virtual camera (in the function called by the button) placed where you want the pan to go to and give it a high priority number
the virtual camera should be disabled initially
If that still confuses you then re learn about virtual cameras in cinemachine
hi I use code: Debug.DrawRay(transform.position, directions[i], Color.red);
but I don't see those lines
I use Gizmos but it doesn't help
Hm I do have the priority switch set up, should I type the button on click() in the enable field?
Where are you looking to see them?
Which object is this script attached to?
What is directions[i] resolving to? (debug it)
And is the code even running?
private void CheckForPlayer()
{
CalculateDirections();
for (int i = 0; i < directions.Length; i++)
{
Debug.DrawRay(transform.position, directions[i], Color.red);
}
}
private void CalculateDirections()
{
directions[0] = transform.right * range;
directions[1] = -transform.right * range;
directions[2] = transform.up * range;
directions[3] = -transform.up * range;
}
I'm looking in "Game" like in tutorial
when do you call CheckForPlayer?
public class Spikehead : EnemyDamage
{
[SerializeField] private float speed;
[SerializeField] private float range;
[SerializeField] private float checkDelay;
private float checkTimer;
private Vector3 destination;
private bool attacking;
private Vector3[] directions = new Vector3[4];
private void Update()
{
if (attacking)
transform.Translate((destination - transform.position).normalized * 10 * Time.deltaTime);
else
{
checkDelay = Time.deltaTime;
if (checkTimer > checkDelay)
{
CheckForPlayer();
}
}
}
private void CheckForPlayer()
{
CalculateDirections();
for (int i = 0; i < directions.Length; i++)
{
Debug.DrawRay(transform.position, directions[i], Color.red);
}
}
private void CalculateDirections()
{
directions[0] = transform.right * range;
directions[1] = -transform.right * range;
directions[2] = transform.up * range;
directions[3] = -transform.up * range;
}
}
this is my code for this
checkTimer is always going to be 0 so your if (checkTimer > checkDelay) is never going to happen
use Debug.Log in the future tomake sure your code is running as expected
!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.
Perhaps you didn't fully understand how priority works. the highest priority virtual camera that is enabled is what gets used by cinemachine.
Therefore we can disable and enable one with a high priority number to control when that "takes over".
e.g.
[SerializeField]
CinemachineCamera panCam;
[SerializeField]
Button button;
private void Start()
{
panCam.enabled = false;
button.onClick.AddListener(() => panCam.enabled = true);
}
why did that work for you!??
thanks
hmm I think that's what I was trying to do, I tried this method using the Input.System. Then I realised too late that the input mentioned there can't include the button I already made on there. How can I edit my script to use ur template?
Sorry did you mean some input key/controller button and not a UI button?
Well yea... I might have gotten it confused since I thought the inputs could include UI buttons, it sounded like the same category
hi im new to coding i was watching some tutorials for 2D but problem is its in old input system should i also learn old input system is it easy to convert its coding to new system or should i start from learning new input system and ignore old tutorials
So I'm kinda stuck atm, Im not sure how to follow up from here, might have to rework my script. I'll try it the way u scripted ur example
nah ui buttons are fully seperate. Input system is for physical input devices (mouse, keyboard, controller, touch screen)
aw man, thought mouse included sth like click buttons ToT
left and right click? ofcourse it does
Wsp
go with the new one because you will need to learn about it at some point
hey guys im new to unity! im using unity 2d to create a side scrolling game - quite simple but im stuck as the player just falls through the tilemap... i have followed some tutorials and nothing is being resolved. All the solutions say 'check composite collider' but there is not an option to do this...i have followed the tutorials exactly how they are supposed to be as well
do you guys know any resource or video to study new input system 2D ?
does the player have a collider
thx
lets get you out of tutorial hell early
make sure isTrigger is not checked
and does the tilemap also have a collider?
yeh the tilempa has a collider, is trigger is also not checked
is it a TilemapCollider2D?
yepp
and then did you add a composite collider 2d too? like all the tutorials are saying
yep
can you send ss with player components and groudn components
and on the tilemap collider, you checked "used by composite"?
you see it doesnt give me an option to do that
can you show it?
(I just got here so I don't really know the proper format to share code)
But I have a action input variable that reads the player WASD input in respects to a 3D space and is read as a vector3 in the script
[SerializeField] InputAction playerControls;
...
void Update()
moveDirection = playerControls.ReadValue<Vector3>();
Then in the fixed update I have a playercontroller (previously referenced in script use the playercontroller.Move() funtion
void fixedUpdate()
playerController.Move(moveDirection * playerSpeed * Time.deltaTime);
Then I have a basic camera movement function for the player
mouseX += Input.GetAxis("Mouse X") * Time.deltaTime * sensitivity;
mouseY -= Input.GetAxis("Mouse Y") * Time.deltaTime * sensitivity;
mouseY = Mathf.Clamp(mouseY, -60, 60);
playerCamera.transform.rotation = Quaternion.Euler(mouseY, mouseX, playerCamera.transform.localRotation.z);
transform.rotation = Quaternion.Euler(transform.rotation.x, mouseX, transform.rotation.z);
The end goal here is to have the player's movement direction adjust with the way they are facing (as you see in many first person game) but I can't figure out how to stop the player from moving around based on world scale and have them move around based on local scale.
i tired setting composite operation to none
you can rotate the input vector using the players world rotation
also i am curious why you are using the new and old input systems together
what's the Grid component for? haven't seen that before.
I think it was there by default
Ok so I've tried to replace my current codes to match the template, but I'm not sure how to go on from here
dont just mindlessly copy it... You didnt even clarify what kind of button you meant...
The point of the example was to illustrate how we can enable/disable the cinemachine camera in code
and my example used a UGUI (ui) button
Sorry, I thought it fits cuz I do have a UI button set up
The button I want is from an image I set up in the canvas, how can I clarify that?
cool then that is a UI button. You confused me with talk of the input system
correct your spelling and it should then work
yea I confused myself too lol
also images of code suck, send code as text or use a !code site
📃 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.
Ok let me give it a try 👍
well I am learning the new input system and i struggled to get it to work with the mouse so I put it off and then decided to try again with WASD and it worked out pretty well so I am probably going to go back and quickly modify the code with the new input system (also rotating around world space doesn't work)
just set the composite operation to something and it should work
they removed that "used by composite" thing because its not needed
it does work:
Vector2 input = move.ReadValue<Vector2>();
Vector3 rotatedInput = transform.rotation * new Vector3(input.x, 0f, input.y);
i tried them all. its not working :,)
Well I tried this and landed at the same result where the player just moves in 4 direction in world space regardless of how the player is facing (you can see this with the static position arrows while the playercamera is facing a different direction)
you can use your cameras rotation instead then.
The point is that we rotate the input vector using some Quaternion so its oriented correctly.
If your "player" never gets rotated then dont use its rotation for this process.
Ideally you rotate your player on Y and rotate your camera on X (only for both)
THEN this should work much better
Can someone help me I want to make a first person game but use this free model i found on the asset store called banana man https://assetstore.unity.com/packages/3d/characters/humanoids/banana-man-196830 and give him movement and eyes. I tried using the free offical unity first person controller prefab and replacing the character but that doesn't work please i need some help
Well the player does rotate with the camera (sorry for not carrifying that) its just that it keeps forcing the player to move around the world space with the .Move() function of the playercontroller (this is the same for linearvelocity with rigidbodies) and I think I just need to move the player based around its local position/rotation
unity doesnt use nuget so
Oh well you can use functions in Transform to go from a local to world direction vector if you need world space:
https://docs.unity3d.com/ScriptReference/Transform.TransformVector.html
Is new input system easier than old
https://github.com/fatoastcatbruh/Script
Really need some help fixing something. Im making a multiplayer card game about diseases. I need to update a bool in the enemys BodyUI script from the player who plays the card "HC()". Right now the player playing the card doesnt have access to the other players BodyUI script for some reason. Pls help thanks 🙂
Can someone help me I want to make a first person game but use this free model i found on the asset store called banana man https://assetstore.unity.com/packages/3d/characters/humanoids/banana-man-196830 and give him movement and eyes. I tried using the free offical unity first person controller prefab and replacing the character but that doesn't work please i need some help
Can i get some help with my game
Yes, and it's the preferred. Best to watch tutorials on how to setup. Will save you time in the long run . . .
we are going to need a lot more context
wdym
Guys I just need a help.
We need to know more about your setup
how your handling certain things
exactly whats not working etc.
Don't ask to ask, just ask . . .
Is it different to code than say using vertical and horizontal to move
How to change the brown grid colour into other colour can you give me some guidelines thanks.
Yes, you access the controls/values differently, but once set up, it's easy to configure and use across all of your scripts . . .
I don't know how to give my player movemnt and really can't code so i am asking if anyone has a video or an asset the allows me to eaisly give a humanoid such as this https://assetstore.unity.com/packages/3d/characters/humanoids/banana-man-196830 to be controlled by the player and have a camera in the first person perspective
Hmm ill look into it for next project thanks
theres no drag and drop solution for what you are asking
not without understanding a couple of nuanced things
you are best off watching seperate tutorials for player controllers and animator implementation
?Huh
do you have any recomendations
for the animator i can recommend this series:https://youtube.com/playlist?list=PLwyUzJb_FNeTQwyGujWRLqnfKpV-cj-eO&si=CvNJ8VnEjayeuQY-
as for the controller theres a million tutorials out there
necesito ayuda
Guy’s I already send it out can someone give me some advice
Over here
Check the refer over here.
ayuda
Edit ---> Preferences ---> Colors
Where is the Edit?
como ago para que funcione el sistema de puntos de recolecion
I couldn’t find it.
Program menu, next to File
most people here wont be able to help you if they dont understand you
Like top of your screen literally of the window bar
Uhh, in the toolbar . . .
Sorry, this is an english server. Most people won't be able to help if it's in another language . . .
Oh, that's a broad question . . .
To collect the trash bags on the map?
YouTube “Unity coin collect” should be fine …
Easiest answer is to create a class that stores points. When an event happens (where the player gains points), add X amount of points to the total points . . .
Go to the recent picture sent from the other guy. Look at the top of screen. Top left. “Edit”
What have you tried?
It's the menu area for the editor. The same place where you save the file . . .
Hi, how can i make Don't starve camera rotation in unity 2d?
now when you say camera rotation do you just mean a camera you can rotate every 45 degrees
or do you mean like a system that automatically updates sprites relative to the cameras position
so everything appears to be consistently facing the same direction relative to the camera
actually i am still learning game dev so which one would work well?
they would both work
well the first one can be done within one script
this is a question of how you want your game to work
but the second one is a crazy amount of effort to get right
i did something pretty much exactly like that
I find the edit
its gonna involve a lot of animation states and transitions so youre pretty much gonna have to handle most of the animation updates through code for example
i used animancer
this looks really good. You just rotating the camera?
yeah the camera rotates at fixed 45 degree angles
smoothed it out so it looks seamless
Which one
but the sprites on the characters dynamically updates
so it appears as if they are always facing the same direction regardless of cameras rotation
guys i'm having some trouble with my camera and i cant seem to figure out why, so as shown in the image below i got a player prefab which has a camera which follows the view of the FP camera (from cinemachine). now im trying to make it mutliplayer but everytime a client joins the game, my camera object gets his live camera (the camera it follows) set to the newly joint client, how do i fix this?
it also requires an 8 directional sprite set up*
that means for every animation you have you gotta have 8 more like it.
hi i need help with input actions 2D
Thanks a lot
does the camera actually exist in the scene outside of the prefab?
You should destroy/disable any cameras and cinemachine cameras that are not for the local player
or - only add them for the local player
yeah if the host spawns or a client spawns their respective camera gets created
hmm ok i can try to look into that
do you understand why? Your issue is simple
you're making a camera for the other players
and the camera is working
so that's what you see
im trying to do basic movement script adapted to new input system idk which functions to choose
you would need to make functions to handle the input
make them
then select them
yeah i understand why, but im just very new to networking so i just have no idea on how to code that but ill figure that out now. thx!
pretty simple. Something like cs if (!isLocalPlayer) DestroyCameras();
(translate that to however your network framework does things)
I deleted default inputaction file and create a new one. But i am receiving this warnings. How can i fix it?
i cant find functios from my script selection
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.15/manual/QuickStartGuide.html i referenced from here while writing script is there something i did wrong?
because you didn't write any. But your code looks like it's just directly polling the input data in Update so there's no need to be assigning anything in the inspector anyway, assuming you actually hooked up the moveAction reference
Check your UI input module
looks like it's trying to read from an action asset that doesn't have the standard UI action map.
Actually since you're using InputSystem.actions there is no reason you should also have the PlayerInput component on your player at all. Remove it
yo it actually works
where is it ? 🙂
On the EventSystem object
alright thank you
but the problem is that the host's camera lerps towards the position of the client's camera (not the actual camera, just the cinemachine camera). so if i would just destroy all cameras it would still lerp towards that cinemachine camera, so should i just destroy the new cinemachine camera then?
it's a new project and i dont have eventsystem object
also i have a question
Reread what I wrote:
You should destroy/disable any cameras and cinemachine cameras that are not for the local player
yes you do
does someone knows how to variable jump height with new input system coding
or is there any resource or video i can check
it's no different from how you would with the old input system.
once you get the input data, the code is the same
i just created a canvas and eventsystem appeared. Thanks
i dont know old input one too so if i watch tutorial on old input variable jump height can i use it on new one too?
do yoiu have multiple scenes or something? What objects are in your scene?
Yeah you’d have to use the 3 provided context types, started performed canceled
the logic is the same, you just need to apply it using input data you get from the new system
The main idea is you have to know “how long the button is held”
no he wouldn't
it's completely a new 2d project. there is only a few objects in scene
not the way he is doing it
Okay, no he wouldnt
when and where did you see that error
i deleted default inputaction file and created my own
YouTube “unity variable jump height” pick the newest & shiniest looking videos
aight
but that error only comes from the UI Input module
so it would only happen if you have one
i didn't understand 😄 i just created a canvas and eventsystem object appeared. And i remove inputsystem component on eventststem. Everything works now
your UI won't be interactable without the input module
i will add again when i need it. still learning game dev 🙂 Thanks a lot
https://docs.unity3d.com/6000.2/Documentation/ScriptReference/CharacterController.Move.html
// Jump
if (jumpAction.action.triggered && groundedPlayer){
playerVelocity.y = Mathf.Sqrt(jumpHeight * -2.0f * gravityValue);
}```
literally the whole point of why I sent that line.. That is the new input system
Thank you
thats just one of many ways it can be done
don't you have it already ? the default Action Map asset already comes with FIre, Jump, Move etc.
you don't need any interaction. Delete it
i made new action map asset
alright
there's a default interaction that's just fine for your needs
i dont have something named gravityValue "float gravityValue = 3f;" would this be enough
i set my player's gravity to 3
also i dont PlayerVelocity but its just rb.linearvelocity right?
yes becuase it was an example for the input itself, if you're using rigidbody you would need to assign the y value of linearVelocity for the jump or use Impulse
thats not important if you're using rigidbody already multiplied by Gravity if its on
its very simple
either do
rb.linearVelocity = new (move.x * speed, rb.linearVelocity.y)
//Jump
rb.AddForce( Vector3.up * jumpForce, ForceMode.Impulse)
or
rb.linearVelocity = new (rb.linearVelocity.x, jumpForce)
You can post here and someone or me would likely see it, as long as you provide all proper context
alright
thanks for help
'InputAction' does not contain a definition for 'action' and no accessible extension method 'action' accepting a first argument of type 'InputAction' could be found (are you missing a using directive or an assembly reference?) im getting this error for this "if (jumpAction.action.triggered && isGrounded)" i hope translation is true
@rich adder
well if you looked at the docs I sent, jumpAction is defined as InputActionReference which you probably did not declare it as that
public InputActionReference jumpAction; // expects Button
ill check it
ActionReference lets you drag n drop actions from the ActionMap directly
not a code question #💻┃unity-talk
if you're talking about the Gray part of the skybox, you need to assign your own skybox called "procedural skybox" and then you change those tints
is CharacterController component only for 3D?
yes
So I have to create another platform?
And than delete this project to refer a new project
what do you mean another platform ?
Like open a new procedural skybox
no you create a new material and assign it that shader
How to do that
then you assign that material in the Skybox field of the Lighting tab
Fair enough thanks btw
i created 2D physics material made friction and bounciness to 0 wanted to add it to Player/BoxCollider2D/Material but i cant add it
oh its not 2D
mb
Do yall have any recomendations for how to learn c# or whatever the f unity uses cuz i can follow tutorials only to an extent and they all sound like giberish to me
check resources pinned here
!learn too
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
thanks
also something like this before tackling unity is a good idea
https://learn.microsoft.com/en-us/shows/csharp-fundamentals-for-absolute-beginners/
these are the building blocks to most of everything you will be doing
ok thanks
Unity has its own API (functions and patterns) but harder to understand if you dont already distinguish between the two early on
📃 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.
https://paste.mod.gg/civofmelllor/0 Error "Assets\Adam O'Keefe\FinalCharacterControler\Scripts\PlayerLocomotionInput.cs(6,72): error CS0426: The type name 'IPlayerLocomotionActions' does not exist in the type 'PlayerControls'"
A tool for sharing your source code with the world!
.. you're new to coding you should not be messing with premade code especially you don't understand
I am following this tutorial https://youtu.be/muAzcpAg3lg?t=752
In this series, I'll be going over beginner through advanced topics for building a complete player controller, both for 1st and 3rd person. We'll covers topics like movement, jumping, slopes, wall handling, step handling, animation, blend trees, Mecanim, Cinemachine, avatar masks, animation layers and multiplayer.
This is a free complete course...
your input action asset doesn't have an action map named "PlayerLocomotion"
oh it is named PlayerLocomotionMap
why even ask for how to learn c# then jump immediately to something this complex lol
You need to go back to around 6:20 in the video and make sure you do everything the same as the tutorial

