#💻┃code-beginner
1 messages · Page 203 of 1
yeah i saved the code and wdym?
why is networking so hard
because you can't be lazy about your serialization and data coupling
Do you still have an animator on the object, and does that animator have a transition into the clip you were playing
i want to add a logo at the start at the application, near the unity one. is it possible? if yes how?
i am making an AR app, is it still posisble?
It is possible. Make a scene
Yes there's literally an entire section in the player settings for adding a splash screen
ok then? finally i can make screens
Project Settings -> Player
wait were project setting is?
oh found it thx
Most people in this channel would definitely recommend you dont do multiplayer as a beginner. This is like asking "why is flying a plane so hard" when you just learned to ride a bike. Some things are not meant to be done early on in your career and that's just the simple truth of it
what is default cursor? in project settings > player
Why are you looking at the cursor
also you can check the page I linked for what anything does
idk, i see that option
Definietly. Maybe try Coop local multiplayer first
Yes, because it's on the page. Why are you trying to edit it though
you were not asking about cursors
i found that option under the icon, i need also the icon
why do i get this allert when i start the app?
Multiplayer is still multiplayer. Local coop is still gonna be harder than the basic game, since this is the beginner channel I wouldnt recommend any at all. It's still gonna require them to use mostly proper code architecture which most beginner tutorials do not follow
I completed all Unity pathways. In junior programmer they literally ask you to make a coop game
local multiplayer
Currently 3/4th through junior programmer. Is that task the last one? I’ve taken Unity essentials. What is the next pathway after junior programmer?
If I remember correctly they ask you to do this for the bonus challenge of car game
I think after junior programmer you are pretty much set to make simple games on your own getting help from Google
@barren violet
Do the bonus challenges. They teach you a lot (in my opinion)
Ok cool. I look forward to gettting there
and If you decide to take other pathways after junior programmer dont dive into it right away.
practice what you've learned from junior programmer first
Actually if you are 3/4 done with junior programmer you should have been given multiple bonus challenges to do
Yes but I haven’t came across any coop
Thx
Not really sure what you expect as an answer, my initial message wasnt addressed towards you. I havent done the pathway myself but i doubt it is asking you to make a full game
Plus it is walking you through how to do that specific game I would assume
Which would help, but not every game is the same
[SerializeField] private UISlot UISlotPrefab;
//or
[SerializeField] private UISlot uiSlotPrefab;
What do you prefer for abbreviations with private fields?
hey friends, i've read somewhere that instantiating numerous identical copies of a prefab from a game object, eg instantiating identical coins from an enemy when they die, is not hardware efficient, if that makes sense. what are the alternatives? is object pooling significantly better?
It is not a game of course. Its just for basics for "beginners" as you said
an introduction
and they ask you to do this like one day after you start that pathway
so its not that hard its not that advanced stuff to make local coop
You can find what the actual standard is online, but personally would do the 2nd one regardless of what the answer is
yeah but feels bad so maybe the best thing to do is just rename it lmao
Object pooling is a way of reusing objects. You will have to instantiate them at some point regardless. Depending on the use case, it really might not matter. Targetting PC and you these coins spawn like once a minute? Then itll have 0 impact on performance
thanks for the tip
I've got another question which i'm going to try my best to articulate. in a roguelite/like, when you have a load of items that affect a character in passive ways eg add a poison damage to an attack or give a character a stat it previously didnt have eg + 10 damage reduction, do those stats need be written into/exist in the initial character script so they can be modified by items down the line? so the stats already all exist within the character script but gaining the items then changes the stats/variables in question? I guess another way of articulating this is, is it possible to rewrite one script from another at runtime, assuming im not using scriptable objects (sorry if this is a bit confusing, im new here)
This is just a matter of defining what the base stat is, and then adding to it based on your list of items. You will need to define what a stat is so you can add to it, and it's possible you can give a player no stats then add them to like a dictionary. I find it better to just give them all stats but Initialize them all to their default value (likely 0)
you can pretty much give everything an ID and just write those if you wanted to
I just use enum which is basically the id
Yeah, some identifier + lookup table
if you did have some like random stated weapons that generated with a range of stats, then you'd probably have to write those as their value types.
yeah the default value (0) is what i've done in my very first prototype but I didnt know if theres a better way to do it. its not really the items i'm worried about, its more about oh now I want this character to have an effect or on hit/kill effect it previously didnt have, does the action need to already exist within the script for it to happen or is there some way I can inject the variable, and then add it at specific points within the script at runtime
scriptable object your kill effect and add a identifier
on load, lookup what the ID pertains to and construct your object again.
I have a scheme that copies the SO's asset GUID into the SO
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
public abstract class Identifiable : ScriptableObject
{
[SerializeField] Guid _guid;
public Guid Guid => _guid;
#if UNITY_EDITOR
void OnValidate()
{
var path = AssetDatabase.GetAssetPath(this);
_guid = new Guid(AssetDatabase.AssetPathToGUID(path));
}
#endif
}
It uses a custom Guid class
System.Guid is non-serializable
i got 1 more. is there a more effecient way of setting an enum from one script to another, than what i've had to endure here: (bear in mind the enums are exactly the same across the 2 different/separate scripts for the 2 different/separate gameobjects)
I use Json.NET to serialize and deserialize data. I have a custom converter for Identifiable that looks the GUID up in a dictionary that I build before the game starts
ever heard of switch
I wonder why that is
nope!
doesnt unity have a GUID struct?
why do you need the pile of if statements?
are these two different enum types?
Seems to be just a string?
https://docs.unity3d.com/ScriptReference/AssetDatabase.AssetPathToGUID.html
no theyre exactly the same, but theyre in 2 different scripts and I cant work out a better way of doing it (im new to this)
that means they're two different enum types
assetpath is a string and that's kinda what I use
you should just declare one enum type and use it in both places
guid idea seems neat
This breaks if you rearrange your assets
the GUID is nice because I can rename and move my assets without breaking existing save data
Yep
I've it onvalidate
Right, but existing save data now has the wrong asset path
The GUID is eternal.
(and fixed-size)
I also like to keep my OnValidate very lightweight or non existent
But sometimes its needed
I'm not a huge fan of the giant pile of OnValidates, yeah
yeaaah, something I was going to change eventually anyway
I have another place where I can't really do that
I also use GUIDs to identify specific components in my prefabs
ok this sounds like what i'm after
I have to manually click a "generate GUID" button on those
I guess I could check if the guid is all-zeroes in OnValidate
ah nvm..weird could've sworn this was visible in inspector for me
Can you give an example of this?
:\
Hello, how can I activate an inactive object when I approach it with my character? without increasing fps?
Maybe in debug inspector
public abstract class Module : MonoBehaviour, IConfigurable
{
/// <summary>
/// Uniquely identifies an instance of a module attached to an entity.
/// </summary>
[SerializeField] public Guid guid;
#if UNITY_EDITOR
[ContextMenu("Regenerate GUID")]
void NewGUID()
{
var so = new UnityEditor.SerializedObject(this);
so.FindProperty(nameof(guid)).boxedValue = (Guid) System.Guid.NewGuid();
so.ApplyModifiedProperties();
}
#endif
Hmm or not
I love casting from System.Guid to Guid
inactive objects still fire Collisions and Triggers
that's not very intuitive
OnTriggerEnter actually works on inactive objects for specifically this use case. It's a very unintuitive use case, but put a trigger on it and then you'll be able to put a script on it to enable itself when the player enters its trigger
you mean disabled components?
in debug mode it shows the field but its all 000s? wtf
i dont think this was meant for me?
an inactivated gameobject can't possibly collide
It was not
wrong reply, my bad
was aiming at Osmal
It actually can and it's weird
Just triggers though
Really?
That sounds terrible
Are you sure you're not thinking of inactive components?
no, it's Unity standard for waking up sleeping objects
You know what I might be, let me try testing it
I did not know that collision and trigger had this feature. Thank you very much for your answers.
It does say somewhere in the docs that it's meant for exactly what steve said
I can't find it
thank you too
I am checking right now
something something in response to colisions
Because this is true for disabled behaviours
Behaviours are disabled. Game objects are deactivated.
yes, nothing happens
Disabled behaviours still receive a bunch of Unity messages
Okay, yeah, you guys are right, if the object is disabled, no message. But it does work on components that are disabled
Ah found it
Collision events will be sent to disabled MonoBehaviours, to allow enabling Behaviours in response to collisions.
deactivated 😉
If you disable a GO in a physics callback or during a physics timestep, that GO can still be hit by physics queries until the actual update has happened
it's useful to keep the terms separate to avoid confusion
Yeah, good point
Collision messages are sent after the physics update
Oh, I misunderstood your message.
That's a corner case I haven't really looked into myself!
(I missed the "queries" word :p )
😄 Yeah it's a pain, it means you need to maintain the state and can't rely on object's active state for the hit logic
I guess disabling the collider is a safe choice then?
Or does that suffer from the same thing
I can't actually confirm that. I do not know. I maintain state for things that can only be hit once
I'll keep that in mind nevertheless - thanks
hmmm not sure if its related, weird... unity lets you run methods on referenced script on disabled objects
great name change, can any other foo please stand up and make themselves known
Yeah well in C#'s eyes they are still there like normal objects
yeah thought unity would do some weirdness on disabled object, never had tried it. Good to know 
Yes. Unity has no power here.
That's an important thing to realize.
generally the only things that don't run on a disabled object are Awake, OnEnable, Start, Update etc. The Events will all still be invoked
Also, you can call methods all day on a destroyed Unity object
If you have a reference to a destroyed Unity object, you can do whatever you want with it
You will get errors if you try to use a Unity property.
is there a way to get the position of the where the middle of the camera is?
ofc there is
or i suppose the cameras local 0, 0
But beyond that, Unity can't "destroy" the actual C# object
camera.transform.position
I forgot, is an UnityEngine.Object == null when it's being destroyed?
I forget if that's true during OnDestroy, etc.
depends if you want world space or screen space
The object compares equal to null, but that's just a trick. The reference remains.
In screen space or in world space?
There is no 🥄
and there is no null
Camera.ViewportToWorldPoint(0.5f, 0.5f) is handy for screen space center
idk much about world space and screen space
yes, Viewport space is resolution-independent, so it's easier to reason about
well, you'd better be ready to learn!
time to learn
screenspace is where your mouse cursor live, pixel coordinates.
worldspace is where gameobjects live
Learn OpenGL . com provides good and clear modern 3.3+ OpenGL tutorials with clear examples. A great resource to learn modern OpenGL aimed at beginners.
that's a fun one
World space is 3D coordinates. Screen space is pixel coordinates (0->Screen.width, 0->Screen.height) or normalized coordinates (0->1, 0->1)
- World space: a position from the point of view of the world. It is independent of your choice of parent.
- Local space: a position from the point of view of yourself
- Screen space: [0,0] to [width, height]. Z is the depth, measured in meters
- Viewport space: [0,0] to [1,1]. Z is the depth, measured in meters
Yeah that's a more valid explanation
Your transform.localPosition is your position in your parent's local space
If you have no parent, then transform.position is transform.localPosition
so basically if a have a game where i move and the camera follows the player, even when going somewhere else, with screen space say, the bottom left corner would always be 0, 0?
Correct
camfollow script? obligatory cinemachine
and world space is well, just the worlds cords independ on what goes on
And Camera class has methods to convert between world space, screen space and viewport coordinates
I cannot detect inactive objects with collision.
Yes, we found out I was a bit mistaken. It works on disabled components, but not on deactivated objects
Is one of these better than the other, performance wise? As in, is there a good reason to keep the buffer global (I do not need to track the buffer elements between function calls)
void doThing()
{
byte[] buffer = new byte[1000];
// do stuff with buffer
}
As opposed to
byte[] buffer = new byte[1000];
void doThing()
{
// do stuff with buffer
}
how often to you call doThing?
The first one allocates every time you call doThing.
Do you call it often? Having it in the class (your second option) will allow you to not allocate a new array every time
Which would produce garbage
How can I detect it? Isn't there a method?
I've gotten major GC reductions by moving a List<T> out of a method and into the class
Typically a few times a second, but it could go up to 20-100 times a second
and just clearing it each time I need to use it
I think what you'll have to do is to make a second object with the trigger, and have that object enable the original one
this is the typical memory vs speed balance. which would you prefer?
i wouldn't call this a tradeoff at all
then declaring the array outside of the method will be much more performant
unless this method is only ever called very very infrequently
You'll be holding onto that array forever, sure, but holding onto memory is way better than allocating and freeing it over and over
either you have the memory allocated all the time, or you spend time allocating it each time.. how is that not a trade off?
because garbage collection is a huge performance consideration
the time taken to allocate the array is secondary to all that trash you're producing
GC counts as "time"
I'd say it's more memory-heavy to be producing garbage
it puts more pressure on the allocator
this is game dev, when is speed ever a secondary consideration?
If you allocate a new one every frame time, you might be consuming more memory, right? If it is called often
I think I'll do that. Thank you very much for your answer. Good evening.
Since it stays in memory until it's collected
until the GC cleans it up, yes
initialization
my ide yells as me when I don't make nonalloc containers for casting each frame
so I must do what it says
It's both slower and more abusive of your heap to allocate constantly
A temporary allocation only wins if the method is used so rarely that there are usually no allocations
Could always set the array to null when you know you won't use it in a while
this does remind me of something
I have an AI planning system that generates a lot of garbage
Yeah, that kinda stuff tends to need a lot of lists etc
It's doing A* and has to generate a bunch of nodes as it explores
When it's done, every single object it allocated is thrown out
I'd love to be able to put this all in a scratchpad that I dispose of at the end
use a pool?
Yeah, I might just do object pooling.
Each state contains several hash sets to hold world-state
Secondary question. If I opt for a global, persistent array, are there any performance considerations (not memory, not too concerned about that in this instance) for grossly oversizing it? Making it 4000 bytes, say
The objects the hash sets store are all value types
I didn't see any obvious way to do this in regular C#
no
size as power of 2 perhaps?
Why?
I know that you can use a temp allocator with NativeArray, but that's not helpful here, since I'm using managed types
When you run out of space, reallocate and double your capacity
This is basically what a List<T> does.
maybe you should just use a list!
...well, actually...
I should probably start initializing certain lists with a capacity
All of these hash sets and dictionaries are storing value types
If I know the approximate maximum items for them
and those value types are storing primitives like float
this will force it internally to be exactly aligned in memory.. e.g. if your size is 4096 you can specify an index with exactly 3 bytes
Maybe I can just allocate a big pile of NativeHashSet and NativeHashMap with the temporary allocator
at that point I might as well bite the bullet and completely Burst this thing
Is there anyone that can help me with a terrain generation script? (I'm new to unity and game dev in general so I'm not exactly sure what kinda questions to ask)
if i stay still, everything is fine, then when i move the box colliders, rigidbody ect get set to None and it gives me the error Object reference not set to an instance of an object
Plenty of helpful people here, but we need a question to be able to answer
code
Terrain generation is not exactly a beginner subject though, at least for your first game
Popularity of MineCraft etc got people thinking that it's easy I guess
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
okay bugfixing this myself (i am learning) it has to do with my Animator
thanks! havent used discord before
cool - I had a terrain generation script working for a minecraft-esque game (I know - why the hell is a beginner working on this) and it worked on a single thread but had a level of detail system implemented where it merges blocks further away into a single bigger block. I've now tried to multi-thread this by using Burst and nativearrays and I currently have a single persistent array that's causing a leak but I can't exactly dispose of it at any given point.
Sounds like you have programming/C# experience?
I haven't really worked with Burst though - can't help with that, maybe someone else will
I've got tons of it but never in the gaming area - I work as an .NET dev otherwise for work
(Burst caused random crashing on my non-LTS unity, only took me 1 year to find the cause 🙃 )
that sounds like a wonderful time c':
I'm so sorry to hear that 🥲
Honestly you might as well ask in #archived-code-general
would it be better if i handled animations in another function?
being upgraded as we speak Q_Q
if isDev = #archived-code-general
if isDev && isBeginnerSupposedly is why I thought it was supposed to be here, but thanks!!
isProfessionalWorkingDev = #archived-code-general
😉
I feel like such a noob when it comes to gameDev 🥲 - I've now jumped engines 3 times and barely progressed 😄
What engines did you try?
I went from godot to unity to unreal to unity - the order of progress made in each goes unreal > unity > godot
In any case having prior C#/.NET experience is a huge boost for a beginner
yeah - coding hasn't been too difficult of an issue. The terrain generation was entirely self-directed which I only recently realized was an impressive feat for beginners in the videogame world
not at all, proc gen terrain is merely an experiment in array manipulation and reading the documentation
when my animation changes, it gives me a Object reference not set to an instance of an object I referenced the anim and i did a getcomponent and it still doesnt work
why does my saved animation conditions keep disappearing everytime I enter the project?
the Animator is connected to the player
did you check?
and even in the start i did a anim = GetComponent<Animator>();
like what ?
example
I set bool and integer
I save it
I quit my project. Reenter. Boom gone
showing the full error message and the code would help
I am sorry I don't understand what this means
one sec 🙂
what line
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
What line
By adding it to the top you've made the line numbers worthless, but I assume anim is null
is the game runnig when you save those ?
i've set the Anim in the Player Movement script itself to the playeranim
lol, by adding the comments you screwed the line numbers
Ahaha sir definietly not. If it were a problem that simple I would've solved it by now
Show the full inspector of this object
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
im still unsure where you are setting the bool or whatever
is it not because im using multiple frames now due to using pixelart?
The full object's inspector. You can go ahead and collapse this one since it's quite big to show the rest of it
It is because anim is null
how? i've set the anim
Send the full object's inspector and I'll see
that is what we're trying to figure out
by pressing that plus sign
great Microsoft has renamed Bing Chat to Copilot .....
probably just need to remove
anim = GetComponent<Animator>();
So, this object doesn't have an Animator on it
But i set the animator?
That would be why anim is null because you're setting it to null in Start
so the transition is changing itself ?
yes
yes, and then set it to null, see above
Yes, you set it to the Animator component on this object in Start. This object does not have an Animator so it sets anim to null
I mean I have code for it but
it basically changes itself
code is an if staement so shouldnt matter its just for playing it
the conditions I set keep disappearing after I re enter my project its really frustrating
i am so confused
I had 2 for death. But when I reentered I saw that it didnt play then I checked everything for half an hour then saw that conditions was reset
What do you think this line does
i removed that line
it still gives the same error
and now i set the anim in my script to the proper anim
why, you set the Animator correctly in the inspector but set it incorrectly (to null) in Start. So just dont do it in Start like I said
Show the updated code, and the updated error
hold up, its also giving me errors that my parameters do not exist lmfao?
Show updated code and new errors
since you are helping the guy with animations can you help me too?
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
NullReferenceException: Object reference not set to an instance of an object
PlayerMovement.updateAnimationParameters () (at Assets/Scripts/PlayerMovement.cs:121)
PlayerMovement.Update () (at Assets/Scripts/PlayerMovement.cs:106)
NullReferenceException: Object reference not set to an instance of an object
PlayerMovement.FixedUpdate () (at Assets/Scripts/PlayerMovement.cs:140)
its also weird that its not saying my parameters exist but i guess that because the script is still seeing it as "null?"
You have forgotten to include code in your code
bruh i pasted it
did u save ?
Flashbanged
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
💀
anim is still null. You have at least one PlayerMovement without anim set
And also rb is null for the second error
how is rb also null when i set it in the inspector
@rich adderDo you have a solution?
Did you set it on every PlayerMovement
That definitely sounds unusual, not supposed to happen
They should save even in play mode
When you build something, and then import it as a prefab: how can you check the components of that prefab, without having to place it back?
If you can't do that, what happens if you put the prefab in the hierarchy, modify its components, and place it back in the project assets, wouldn't it prompt issues with references you made?
u can double click the prefab and it'll open the prefab in its own window
all references a prefab has should either be inside the prefab itself.. or they need to be assigned during runtime after the prefab is instantiated into the scene (using coding)
you can't use a reference to something in teh scene w/o the references having errors
Ooh, makes sense now, thanks a lot
Actually I'm quite stupid, it works exactly like all the other things lmao
no prob
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
@polar acorn this never used to be a error, i copied it over from another object, i switched art styles and im now doing PixelArt which uses multiple frames, is it not because its switching frames it doesnt see the original RB or anim anymore?
The error is that anim and rb are null on at least one PlayerMovement component. This is abundantly clear from your errors
Find out where you have a PlayerMovement that is missing one or both of these assignments
I was testing it but could not replicate it, youd have to maybe give more info on how its happening on your end
Errors do not lie. If the code says something's null there, something's null there. Check your own assumptions for why you think that can't be the case because it is always the human that is mistaken and never the error
i dont see it hahahaha
First off, search for t: PlayerMovement in your scene. See all of the objects that have PlayerMovement. Check if any of them are missing assignments
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
only object with PlayerMovement is the player itself, i am checking the code rn
https://hastebin.com/share/voxesadela.csharp
yo my code doesnt know what GetKeyDown is or what KeyCode is
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
the tutorial im following works but mine doesnt
thats cuz its misspelled bro
what
check the code again
typo
alr hold on
What do you want from me?
and its odd that ur using a GetKeyDown for a mouse button..
im following a tut idk anything about coding
hopefully i get better but rn idk anything
normally you'd see GetMouseButtonDown
if(Input.GetMouseButtonDown(0))
{
}```
huh
well ya, just check ur spelling
might try that instead
ur original code should be fine.. only its misspelled
well it was spelling thank you
wait
you apparently dont have that variable
ok
Check after starting the game, when the errors are present
alr thank you for the help
using a b d etc is confusing.. if you tend to share the code often try to use some better naming
hmm changing it here will not affect the original Animator Controller
exactly
I cut my garbage by 90% by using Unity.Pools.GenericPool to pool my planner states (and by just clearing their collections instead of constructing new collections)
It reset again
very handy
While I was in unity
guess what
wasnt even that
Sounds good
try to recreate a new controller ? I'm not sure why it would be happening, the controller is an asset so just chaning in editor would affect it unless u had code changing that somehow
yeah, that's what's going on here
I actually only have 4 scripts. This is a new one Im practicing on. I can send you all if you want?
I'm doing a GOAP ™️
so far the enemy can actually plan to move to the player and perform a multi-step attack
im dreding goap rn 😭
I aim for that too
Any good learning resources? I kinda semi-freehanded it and never finished it
note: my Unity version is the latest
should not affect the asset :\
I hate compiler errors. I couldn't find the code unlocker, and had to delete my entire project
maybe bugs?
I'm migrating to using purely data-based agents so that I can test their behaviour and cooperation in edit mode
it can reason about:
- atomic facts (e.g. "I like making things unalive")
- entity facts (e.g. "The player is alive")
- entity proximity facts (e.g. "I want to be within 2 meters of the player")
One thing I can't do right now is delete facts. that's going to be exciting
you should use LTS versions for the best support.. but yea probably doesn't matter what version you're using
@polar acorn https://gyazo.com/259191b636bbc2dbdda7ec7ca309169e
The animations were made in an older version but should work just fine.
"Code unlocker"?
Turns out that it doesnt like me just replacing something straight up, i had to readd the sprite
It should work fine then
I've been mostly inspired by these two things:
https://drive.google.com/file/d/0B3-H32fPH4lgcWl1alc3cWpZaVk/view?resourcekey=0-wsaTAaiNAi9yUpeBd0BFIQ
https://www.youtube.com/watch?v=gm7K68663rA
You think this is worth a bug report?
If we can't fix it
thank you guys for helping, learned lots, thanks for not just telling me the awnser
if its a bug it'll probably have already been ticketed
to know for sure if its a bug youd have to try it on another project /
especially digi, thank you friend
Hello, I have a problem.
I have a JSON like this:
{
users: [{...}, {...}]
}
Each of these objects in the array have this schema:
- name: string
- age: int
Now I want to apply it to the class Users, so I did that:
struct User {
public string name;
public int age;
}
class GameData {
public User[] users;
}
GameData game = JsonUtility.FromJson<GameData>(rawJson); // rawJson is the json in plain text
But now when I log game.users it returns null. Please help me 🙏
The "aha" moment for me was realizing that A* doesn't need a fixed list of nodes. It just needs you to give it new nodes to explore!
Idk what it's called, but I got stuck with an error CS2012
Well you just did and everything's fine.
u need to show the full context
to rule out its not ur stuff
Thanks, saving those. The talk I've seen but I'll give it a rewatch.
Currently trying to decide on the arcitecture for group behaviours. It's complex as hell lol. Aiming for SWAT-style tactics etc.
Hi guys, sorry for being annoying, does anyone know how I can fit these dungeon rooms into just one square?
I read something about scripts getting "Locked" in VS Code
like this
What is the actual error
F.E.A.R. just faked those
No i meant with ur version
Actually I used it in an older version way before already
(we should chat more in #🤖┃ai-navigation since it's busy in here)
Lemme see if I can find it. As I said, I got pissed and deleted my project
not my first time
Instead of doing that, you should just fix the problem
the requested operation cannot be performed on a file with a user-mapped section open
That doesn't sound like a compile error
Probably, but angry people do stupid things that they regret, and a I rgret throwing away that 4 hours of work.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using UnityEngine.UI;
using System.Linq;
public struct Element {
public int placement;
public string type;
public int x; // spike,
public int z; // spike,
public float delay; // all
public string size; // spike,
public float duration; // spike,
public bool boolo; // all
}
public class LevelData
{
public string name;
public int sx;
public int sz;
public List<Element> timeline;
}
public class GameStart : MonoBehaviour {
public Text levelName;
public GameObject floor;
public LevelData level;
int time = 0;
void Start() {
level = ReadLevelFile();
levelName.text = level.name;
Debug.Log(level.timeline) // "null" is here
}
LevelData ReadLevelFile() {
string filePath = "Assets/Scripts/level.json";
if (File.Exists(filePath)) {
string json = File.ReadAllText(filePath);
LevelData level = JsonUtility.FromJson<LevelData>(json);
return level;
} else {
Debug.LogError("File not found!");
return null;
}
}
}
I simplified the code for discord but here is the full code, and the JSON:
{
"name": "Tutorial",
"sx": 7,
"sz": 7,
"timeline": [
{
"placement": 2,
"type": "spike",
"x": 0,
"z": 0,
"delay": 2,
"size": "big",
"duration": 3,
"boolo": true
},
]
}
It was calling it a compile error itself in VS Code
Or Unity mb
please send it via link
and the data saves ok? is just not loading ?
I mainly came here to grieve the loss that I got throwing all that work away, but also hoping if the future that maybe I could get help with errors like this?
Do you guys mind taking a look at my project?
I don't understand, why? You can't understand the code like that?
hi peeps, going through a C# tutorial rn to learn the language and i don't get the difference between float, double and decimal
would somebody mind explaining it to me like a 5 year old?
lol
just use float
mate im on a phone and its a pain to read on DC
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
as a beginner you'll probably be fine just knowing a float is a decimal
the difference is how precise each one is and how much data it takes to store each one
ok 👍
all the other types are for more advanced things
it's not about usage, i just don't really get it is all
ok no worries
please
unity uses float for pretty much everything, and rarely does double
ya, just dont complicate things until a float no longer works for you
gotcha
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
idek what short or long is, they didn't mention it 💀
also
and the data saves ok? is just not loading ?
oh boy
@gray pondjust be mindful about arrays when using float
i'll learn eventually
idk what an array is either yet 😭 sorry
i dont think u can have an index of float..
float point imprecision if number gets too big
so if you have 3 game objects you can use int. for 1 2 3
eg if your map is hugeeeeee
no its ok
0, 1, 2 * 😈
everything else is fine
damn yeah I still get confused about that
lol no worries.. computers count from 0
well, but yeah lets not go there, (screw you lua and matlab)
lol.
void Start() {
level = ReadLevelFile();
levelName.text = level.name;
Debug.Log(level.timeline) // <------- it logs null
}
so Is there a volunteer who would take a look at my project?
well do you ever write to timeline
but game.users was just a simplified version for the code on discord, level.timeline is the real full code
its a list and those start as null unless you create one
timeline is in the json
if you need help with something specific then ask a question
https://dontasktoask.com
@slender nymphI already did. I think you come just now
Element is not marked [Serializable]
What do I need to change ?
then link to your question or repost it because i don't see it and i'm sure nobody else wants to scroll for several minutes just to find whatever it was you allegedly asked about
add the attribute they sent
add the attribute above it
[Serializable]
My animation conditions get deleted randomly. Navarone tried to replicate it but it worked just fine for him.
put it above all the structs and classes you are using with JsonUtility
are you sure you dont have a another script changing the Animator Controller somehow?
Yes. I can send you all my 4 scripts if you want
4 scripts all modifying 1 animator controller? 👀
not the SetBool stuff, I mean modifying transitions
I don't have
sounds over complicated with 4 things modifing the same controller
1 for animator
3 for other things
feel like i would have one component interacting with the animator that other things call on to do work
disable the script thats modifying the animator and see if u still have issues? that would eliminate the script as the culprit?
Already tried that.
and wat was the outcome?
did it still have problems?
or did the problems dissapear
[Serializable] public struct Element {
-> Assets/Scripts/GameStart.cs(8,2): error CS0246: The type or namespace name 'Serializable' could not be found (are you missing a using directive or an assembly reference?)
Yes. I wouldn't be here otherwise
System
using System; at the top
I don't think it has something to do with the script
ok thanks 🙂
so is it only on this project? i dont recall if you answered this
then its probably #🏃┃animation issue, if its not the script
Well if you could take a look at my project I'd appreciate it
I did answer.
I tried it in an older version way before
It worked fine
then your solution may be to use a different version
before is not now though 😛
It's working now! Thanks @rich adder and @shell sorrel for the help 🙂
ya, i wanna guess that you've added to ur project since then...
u cant use that as a comparison if its not exactly how it is now
Does anyone understand why my player doesn't jump?
maybe something is messing with the isDirty or something
idk much about editor stuff though
ofc velocity ovverrides any Forces also ur missing Impulse
Well will try that than I guess nothing else we can do
oh wait i see you do have rigidbody.velocity.y so thats fine
I think if you add Impulse it will work
maybe if you guys took a look at my project but... anyways
I cant rn Im at work
It dont
still tho.. yea the force is still being interrupted
impulse might fix it
@rich adder just last question: why [Serializable] resolved the problem? Because I put that but I don't know why...
Unity needs it to serialize the class/struct
okay. can you let me know when you get home?
it tells unity its aloud to serialize this type
ok, thanks
sure!
thats a big ask.. ive never seen anyone want to download random peoples projects.
serializing is just a fancy word for saving data in a structured way
I know. I wouldn't really ask it if we could fix it somehow
not saying ur a scammer or anything.. but it happens and people are hesitant to do it
export ur stuff as a unity package and pull it into a different version
that'd be my suggestion
well yeah I am a scammer you got me! Hello this is Unity tech support how may I assist you today?
since u said it works in another version. that might be the only thing u can do..
or in the unity hub u can swap the version ur using to open it
that'd be the easiest way
duplicate the project folder first so if things go bad ur project isnt ruined..
and with the new project just open it with a diff version
tbh testing the same project (a copy) on a different unity version is your best sensible bet rn @mortal bridge
mmhmm.. and if it works in that new version.. then u can send in a bug report
if u believe its the version thats bugged (which if it works on a different version may very well be the case)
but like nav said, a copy of this most recent version..
not the older version u said worked b4
Okay. I have big concerns about version change since some of my shaders were ruined but let me do it. You guys make me face one of my biggest fears
yeah a copy
yes a copy i can do it
You should always do it on copies, and regardless You shouldprob have GIT setup with repo
hey! what is the best way to create health bars for enemies? what i mean is, to show the healthbars on screen, you first have to identify that they are visible on screen. i think to constantly loop through all enemies is not it xD
Nigerian Prince right?
Hmm you could alternatively use https://docs.unity3d.com/ScriptReference/Renderer.OnBecameVisible.html and https://docs.unity3d.com/ScriptReference/Renderer.OnBecameInvisible.html
Hello. I am shakira and I am stuck at airport I need money to get to Paris. I am Real shakira. saminamina ee ee waka waka eee ee
I am very proud to announce that when I tried this in the earlier version I used to work with it worked (at least for now I quit and reentered it was fine) I am proud to be one of the bug finders
so its only broken on ur version of Unity and which version is that?
latest
latest isnt a version
they be updating quick
time to report some bugs baby. better reward me for it. like dont get revenue share or money per install from me
funny
Does anyone know why the monkey just disappears?
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
check the layer order anyway
it's also clearly not disappeared. it's most likely behind some other object, like your background
using System.Collections.Generic;
using UnityEngine;
public class MonkeyScript : MonoBehaviour
{
float targetPositionX;
[SerializeField] private float speed;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
targetPositionX=GameObject.FindWithTag("Player").transform.position.x;
float step = speed * Time.deltaTime;
transform.position = Vector2.MoveTowards(transform.position, new Vector2(targetPositionX, 0.2f), step);
}
}```
is the background a sprite? check the Z pos is > 0
its probably the Order layer though
hey friends, i'm still stuck on my enum issue from earlier. i've got 2 classes with an identical declared (within each class) enum and I want 1 class to set the enum on the other class to match whats in the first one without having to write out each individual change, so it would be more like "spawnedDotZonePrefab.GetComponent<AOEDamageScript>().debuffType = this.DOTZoneControllerScript.debuffType;" but ofc this code doesnt work and i'm not sure what it is exactly i'm looking to type in here for the bit after =
why not just make a property that Invokes an event when changed
and have other enum class listen to it
public MyEnum MyEnumValue
{
get { return _myEnumValue; }
set
{
if (_myEnumValue != value)
{
_myEnumValue = value;
OnMyEnumValueChanged?.Invoke(value);
}
}
}
It works now, thx
interesting, this seems to be getting a bit far ahead of what i currently know.
that’s why he is explaining it to you
properties are ez, they are just fancy methods
but they run everytime you access the prop
you need to understand properties to use C# anyway
it’s a core part of the language
so I have this
i wrote this to experiment with something
and for some reason in the inspector, the value of landed is flickering??
maybe isGrounded is flickering
yeah if you're using the CC grounded then its total shite
this is another situation where I would use a property and not a field
thats so bad
what I want basically
I would make my own grounding
pls review guys, and how to improve, sry for my en:
https://gdl.space/olejitobop.cs
like Sphercast or whatever
why not just:
landed = _controller.isGrounded;```?
but yeah CC.isGrounded isn't the best.
i was testing something so the code is shit
public bool Landed => !_controller.isGrounded;
what I want is to not be able to bhop
like basically whenever I land on the ground
I want the "Jumping" input axis to be reset somehow
if it works dont worry about it
I mean yeah this is expected of CC.isGrounded
use your own grounded check
otherwise it works fine
CC.isGrounded is only true when your last CC.Move call pushed it into the ground
this trips people up all the time
use your own grounded check
dang thats stupid
indeed
its meant for basic usecases
When using a character controller, it is important to include a small amount of downward motion, even when grounded, so that you continue to be in contact with the ground
like it works thats not the issue
i feel like I have to repeat his advice because it is not heeded 
like SimpleMove method which uses gravity, but really who uses that 😂
first time hearing
flicker is very common tbh esp on things like slopes
my english its bad but, ok if i understand what you say now, its ok this version, how improve if its possible, exiting other methods more great?
code with big documentation
Im just saying If its working fine, the code doesnt need to be refactored unless you dont understand it easily
comments go big big
can someone help with this?
What does this mean... I literally pulled the script to the gameObject?
the last sentence is very important
///<summary>Docstring </summary>
Name and class name match
How often do you guys implement the observer pattern in your codes?
then you have compile errors
Make sure that there are no compile errors and that the file name and class name match.
I use events almost all the time
so yeah every project lol
i spam events a lot
like, a lot a lot
whoops
it just says that it doesn't exist?
Events are good, just gotta remember to unsubscribe if needed
honestly after you get a hang of events you never want to go back
that’s just part of the workflow
So go find whatever component is missing a script and remove it
well, I wrote this code, I understand it, and I'm thinking if this method of saving data is good..., maybe there is something faster, you understand what I mean, I'm not experienced in unity c#, sorry if I ask
They seemed a bit intimidating at first, but they really aren't
Ah okay thanks for the answers.
events are an easy way to satisfy the open/closed principle
{
if(Input.GetMouseButtonDown(0))
{
target = Camera.main.ScreenToWorldPoint(Input.mousePosition);
target.z = transform.position.z;
}
}
Newby here. Any quick way to make this a core routine?
what is a core routine
I am then making it my priority to learn now.
looks perfectly fine to me 🤷♂️
Why do you need a coroutine? Do you need it to move over time?
thx, you are good people
public event Action MyEvent; is the most common
delegates can get complicated. Actions are simpleish
I'm making a click and point grid movement system for a turn based game.
why cant i cast a bool to be an int like this?
Where do you use events?
thats now how you cast
(int)
Because int is not a function
It would be (int) thing, not the other way around
oh im stupid
But you can't cast a bool to int
It is kind of hard to wrap my head around events. I watch videos I understand why but never done it myself yet. I wondered if it is widely used.
just make ur own function that does it
🤷♂️ You can do int myInt = myBool ? 1 : 0
thats like saying "i dont want to resort to if else statement"
it just looks funky in my line of code
Alternatively a function int BoolToInt(bool b) or something
But seems excessive iIMO
Let’s say I am loading a level file. My SaveHandler class will invoke an event OnLevelLoad to call anything that needs to be called when a level has just been loaded.
imagine doing that
only madmans do that
regardless you still need return the if else no ?
Or SpawnedEntityHandler invokes OnEntityDeath to call anything that must be called when a given entity dies
i mean its not the main thing
my main problem rn is the bhopping
How would you suggest I go about using the the mouse to move different object on a grid? I'm currently frankenstiening two tutorials together for a grid movement and a point to move tutorial lol. I'm probably gonna look for a tutorial for separate object selection for movement in a moment.
Or PlayerMovement invokes OnPlayerJump to let anything know that the player has just jumped.
Bunny hop?
back hop?
Misspelled for bop i think
hmm okay
big hop?
That's usually a sign you're doing something odd the code is trying to disincentivize by making awkward
Zero context here lol
depending how you detect if jump is pressed or not]
https://gdl.space/vebofequju.cs
First person player controller, except for whatever reason W and D move me one direction (not relative to player) and A and S the other
but ill re-record it then
Here
generally, when a class does something that might cause other things to need to happen, BUT this class isn’t actually responsible for doing any of those things, you want to use an event
How exactly do you define bunnyhopping here
What do you not want to happen?
wtf is a bunny hop
I just use functions that call on each other
its a quake / gold src thing
Jumping again right after landing which often leads to bigger jumps as a game mechanic
So, when I trigger the exit. The exit fires off an event and the scenemanager subscribes then loads the next level?
dont change movedir vectorx z with input
if you hold down jump, the character can just keep on jumping
i want it to have a small cooldown whenever it lands
How do you handle detection if a button is pressed?
So nothing like the classic bunny hop from quake
So instead of checking for button held, check if the button is pressed
New system or old?
how else?
old input system
do you mean a buffer jump or double jump?
what?
oh because you called it that thought he was talking about quake/source stuff
if (Input.GetAxis("Jump") >= 1 && jumpTime > 0f && Input.GetAxisRaw("Horizontal") != 0)
{
isJumping = true;
gravPull.y = Mathf.Sqrt(_jumpHeight * _gravity * -10f);
jumpTime -= Time.deltaTime;
}```
i think he means double jumps
This why I was asking to make sure heh
Why is "Jump" an axis
how else can I change the vector
i literally just explained it and provided a video
No, because it is on the ground, not the air
Double jump implies jumping in the air. Here they jump as soon as they land
because I wanted to make it so u have to hold down the jump button for like half a second before it jumps, as a windup
Ill write you some codes wait a sec
i just see some random jumping bro
you can probably have bool that saves if jump was pressed and if jump is pressed and that value is too return instead of doing jump code.
when jump is not pressed just set the JumpPressed value to false back
then text after it explaining
That sounds like not the right way to do that
This is trying to use a hammer on a screw
They want to HOLD jump, and when they land there is a cooldown before jumping again.
Right Alfy?
it's just not the tool for that
yeah
so on becoming grounded start a timer
oh i see now. that’s an issue with your input system, fam
well the old input system has the whole Sensitivity thing
and i thought itd be useful
so i dont have to write fucked up code
old system is fine
What sensitivity thing?
i’ve never heard it called a bunny hop, since idk of any games that actually want you to continuously jump by holding jump. I’ve seen it before, but I don’t think it is intentional.
you should be using the new input system, with invokes events on button presses
basically we know that the old input system just interpolates between 0 and 1 whenever hold down a key
sensitivity is for telling it how long it takes for it to go from 0 to 1
AFAIK It's not usually a button hold but a button press instead
But I might be wrong
one time it broke an entire project because i installed it
and I was shamed for trying to use it and was asked why didnt i use the old one
Wrong. That is not always the case. It is for GetAxis, but not GetButton
cause its really different from old one
float moveX = 0;
float moveZ = 0;
if (Input.GetKey(KeyCode.W)) moveX = moveX+ 1;
if (Input.GetKey(KeyCode.S)) moveX = moveX- 1;
if (Input.GetKey(KeyCode.A)) moveZ = moveZ- 1;
if (Input.GetKey(KeyCode.D)) moveZ = moveZ+ 1;
moveDir = transform.forward * moveX + transform.right * moveZ;
@dense cypress
and im using getaxis, yeh
it should not break anything by installing it
That's messed up, use whichever you like
it straight up stopped processing inputs last time and I got a shit ton of file errors
it should be simple to slowly transition, replacing calls to the old input system with calls to the new input system
If you got errors i'm sure those are fixable
Use Old input. No need for new unless you want jt
the errors weren't in my monoscripts
yeah, that is not normal behaviour
Tbh I never fully migrated to the new system. I mix both
again, this is not normal
yeahh i could tell
@dense cypressThis solved it?
so my experiences with it are bad
I DO use new entirely, but both are perfectly fine
mixing both will make so new one will work funiky
and I understand the old system much better anyway
adding the plugin should not break anything
I'm just putting it in
Now this is straight wrong
New is more performant
More flexible
And imo easier to use
okay
best part is i couldnt even remove it
New one is much better
you want with what lines to replace these right?
tf
I said I understand it better
not that its better
new one sucks for mouse so I use both
pretty sure that is also not a real thing. it is just a package, and the package can be uninstalled
Ah, misread, sorry
all good :)
I did too lol
i know its probably better
idk wtf you did. are you sure you used the Unity input system package?
lemme rephrase
"I have a better understanding of the old system anyways"
yeah
but it doesnt matter anyway
there was no uninstall button
it overwrote the old one
inputsystem does not overwrite the old input system
well idk wtf was up with it
but I spent like 2 days trying to fix it back then
and ended up having to create a new project
back everything up, and try again
I have no idea how he broke everything with unity import
i honestly doubt it. it is a package
I bet he never opened systemEvent
tbf me neither but i cant say im surprised
It works and they go in different directions but how do I make it relative to the player? and also the player does not stop moving at any point
anyhow
im really not sure how to go about fixing it
I was thinking of adding it as a feature
relative to player that code does it alright already
that u can keep on jumping without cooldown
try resetting movedirection
but ofc add a stamina requirement and when ur stamina hits 0 u cant jump anymore
a while ago I said you how to fix it
but it still looks really weird
you sure you put them in right places? show me the code @dense cypress
sorry i missed it
same jump into bool variable
the problem isn't with the windup thing
on running jump code set another variable of "have jumped"
yeaah I see
and just run the jump code of
_isJumping&&!_hasJumped
like all of this could be fixed if unity had a function for resetting the value of an Axis
nothing stops you from just editing it in runtime
Fixing what? The ability to instantly jump again when landing?
the value of an input axis? how?
rn we talking about it yeah
it has {get; private set} no?
and its not a vector3 its a float between -1 and 1
But you were answered already, what's wrong with using a cooldown/timer?
the fact that I use the sensitivity thing in the inputsystem
so what it'd do is once the cooldown is over after a jump, it immediately gets flung into the air without windup
Don't use GetAxis for jump input, why not just use GetKey
I don't see why you want 'sensitivity' here
because, as I explained it, I have a windup
Like a delay before you jump?
for update you go brr:
if (!IsOwner) return;
moveDir = Vector3.zero;
if (Input.GetKey(KeyCode.W)) moveDir = transform.forward+transform.forward;
if (Input.GetKey(KeyCode.S)) moveDir = transform.forward-transform.forward;
if (Input.GetKey(KeyCode.A)) moveDir = transform.right-transform.right;
if (Input.GetKey(KeyCode.D)) moveDir = transform.right+transform.right
moveDir.Normalize();
for fixxxxed update you go:
if (!IsOwner || moveDir.magnitude = 0)
{
m_Rigidbody.velocity = Vector3.zero;
return;
}
m_Rigidbody.AddForce(moveDir * moveSpeed * 25f, ForceMode.Force);
i dont want to have 3 different timers
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
just for a single jump
oh In fixxxed update it should be ==
I missed it
*if (!IsOwner || moveDir.magnitude ==0)
Predelay/warmup is one, another one is the cooldown after landing. Not that bad
@dense cypress
ig ill rewrite everything then in jump
yep putting it in now
cuz most of it wont work using that
dont forget double equal
yep
work?
How would I make it so the distance between the mouse and the player doesn't affect the projectile's speed? I've been trying to figure it out but can't. In the clip you can see that the bullet is a lot faster when your mouse is far away while you shoot and really slow when it's close
https://gyazo.com/9a5a15373234c6f4f58aed3925c7d2ee
private void shootBullet()
{
if (onShootCooldown) return;
onShootCooldown = true;
Invoke(nameof(removeShootCooldown), shootCooldown);
var currentPlayerPos = gameObject.transform.position;
var newBullet = Instantiate(bulletPrefab, currentPlayerPos - Vector3.back, new Quaternion(0, 0, 0, 0), null);
var bulletRigidBody = newBullet.GetComponent<Rigidbody2D>();
var mousePosition = Input.mousePosition;
mousePosition = mainCamera.ScreenToWorldPoint(mousePosition);
var bulletDirection = mousePosition - currentPlayerPos;
bulletDirection.Normalize();
bulletRigidBody.AddForce(bulletDirection * 20, ForceMode2D.Impulse);
}
exclusively W and D inputs work
Jumping should be fairly separate from input, so I'm not sure what you're having to rewrite
nice
just remove the moveX and moveZ and directly update the moveDir based on the key pressed and add a line to normalize moveDir after every inputs done
that should do it
how do I directly update the moveDir based on the key pressed
Hello, I have a question, what does transform.eulerAngle.y exactly do ? Like I know we get a rotation from the Y axis, but starting from where ? Because if we want a rotation, we need and axis (Y) an "end position", but also a "strat position" (= 0°), and what is it in this method ? Because I want to generalize it from an given vector axis and I'm planning to do that through Vector.SignedAngle(), but I dont know what to put in the from and to parameters. Thanks !
It gets the Y value of a Vector3 representing the object's orientation
my man actually you need to learn it. If I give you codes nonstop you wont learn
Euler Angles are Vector3s that represent a Quaternion in the form of degrees about each axis
@dense cypressyou want resources?
code seems fine as the direction is normalized, so the only thing I can think of is there's forces on the z, but it's 2D rigidbody. Debug the values just to make sure.
Imma try my best to figure it out but yes probably
this gif will probably get obliterated by dyno, but let's try
sweet
oh you know what
this actually makes a lot more sense to me now
friendship ended with euler, quaternions my new bff
this gimbal lock or what
Actually I just realized that you dont need resources for this. You can do it with your current knowledge
no, it's just a demonstration of euler angles
speaking of which I did it, thanks for the help!
each rotation uses the new axis, not the original axis
It's good to know the order that euler rotations are applied in
it works the way you want?
Z, X, Y right?
oh, there's an order?
yep (except for the fact that only the camera rotates and I wanted that for the player but I can fix that myself)
very good. glad to be helpful
Why doesn't the method work like angleaxis then. Would probably solve some gimbal issues.
Euler angles can represent a three dimensional rotation by performing three separate rotations around individual axes. In Unity these rotations are performed around the Z axis, the X axis, and the Y axis, in that order.
https://docs.unity3d.com/ScriptReference/Transform-eulerAngles.html
that's such an odd ordering
It sounds odd at first, but it kinda makes sense to me
I can't explain why though 😄
I'm just used to Y being the 'parent axis'
And X is the child of that, and Z is the child of X
when i click on a letter, it highlights white and then when i try to type to put a bracket or something between it deletes whatever's highlighted
what do
I just know that in fps games you're usually rotating z -> y -> x (xyz) ordering
Press Insert on your keyboard
programming is like walking with no legs. first you gotta analyze the problem (you have no legs) then you should ask for legs from government (in this case me) (lets say they didnt give you legs) then you have to understand where to find legs and finally find legs and walk (problem solved) happy learning
press insert
Above the delete button
Can't add script component 'GridSnap' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match.
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.
silly little things
Make sure that there are no compile errors and that the file name and class name match.
No errors and the names match
That's what got me rn
Show your console
in unity
O mb
did u save it?
error CS2012: Cannot open 'D:-Unity Projects\True TCG\True TCG\Library\Bee\artifacts\1900b0aE.dag\Assembly-CSharp.dll' for writing -- 'The requested operation cannot be performed on a file with a user-mapped section open. : 'D:-Unity Projects\True TCG\True TCG\Library\Bee\artifacts\1900b0aE.dag\Assembly-CSharp.dll''
Oh wait lel
I forgor to close vs code
Im pretty sure vs code shouldnt stop you from loading in the file
And... closing it did nothing
this wouldn't be your code editor's fault
Ugh, I hate compiler errors. They kill new coders
yeah this doesnt work at all
if (jumpCooldown > 0f) jumpCooldown -= Time.deltaTime;
if (Input.GetKey(KeyCode.Space) && windup <= 0f) windup = _windup;
if (windup > 0f && jumpCooldown <= 0f) windup -= Time.deltaTime;
if (windup <= 0f && Input.GetAxis("Jump") >= 1 && jumpTime > 0f)
{
jumpCooldown = _jumpCooldown;
isJumping = true;
gravPull.y = Mathf.Sqrt(_jumpHeight * _gravity * -10f);
jumpTime -= Time.deltaTime;
}
this isn't a compiler error. it's as runtime error
this kind of thing makes me think you have two editors open