#π»βcode-beginner
1 messages Β· Page 817 of 1
Is it used by any renderers
yes it's on a mesh
your user menu controller isn't rendering the material, is it
it shouldn't be
it isn't, hence the question
two things
Have you tried just setting .color?
Have you debug logg the value of the material color before and after you set it?
if you modify a score but never put it in the UI it'll never show up - we're basically asking if you've passed it along to the UI
I have not. Last time I tried something like this with changing a BaseMap texture it took effect in editor time too, which I feel is almost certainly not good practice
I can do that
That is how modifying assets works, itβs not necessarily bad practice but it can have consequences if your not aware of what your doing
I see
Same thing as modifying scriptableobjects, prefabs etc.
I definitely have more to learn but this worked as I meant to describe
public class Test : MonoBehaviour
{
int _number;
private void Start()
{
_number = 1;
int _thing = _number;
Debug.Log(_number);
_thing -= 1;
Debug.Log(_number);
Debug.Log(_thing);
}
}
right, these are value types, they fundamentally work differently from reference types
conceptually, reference-typed values have an identity, value-typed values do not, hence the difference in behavior here.
I swear I looked this up just before getting into it but am I wrong about Awake? Does it not execute even when the object is inactive?
it doesn't execute when the object is inactive, yes
well therein lies the problem I'm sure
what does the word awake mean to you π
one of these methods I've been trying was the right one
ngl i do wish there was like, an OnLoaded thing though
true
well the way the documentation described it, it made it seem like Awake happens "before the game starts" as in like whenever the script instance is first created
and I thought that's why OnEnable was its own thing
Awake only runs once per instance, onenable runs any time it goes from disabled to enabled
OnEnable can happen multiple times whereas Awake will only happen once
So I most likely just need to run this in a function on an active object
well no
also Awake works on activeInHierarchy whereas OnEnable works on activeInHierarchy && enabled
You need to run the function period
ah right
π₯² The more I say the less I know
It be like that
i couldve probably phrased this clearer
Awake works on the gameobject level but OnEnable works on the component level, i guess?
I knew something wasn't adding up when I tried to debug log the steps and nothing was output
Thats why we log asap
Thanks you all
if ==
I know, I'm curious as to why the first screenshot isn't underlined though
and why it works and compiles
is quest a boolean?
no its a scriptable object
AI is saying that means it treats that if as a null check... which makes no sense to me
it still probably doesn't do what you want
because sometimes it's valid, but in the case you got an error, it isn't valid
any assignment in C# also returns the new value. someFloatVariable = 2.0f for example returns 2.0, similarly quest = pinnedQuest returns pinnedQuest which unity evaluates as boolean expression
to be pedantic, unity defines that as implicitly convertible to boolean, which c# evaluates
Why unity Objects (which ScriptableObjects are too) can be evaluated as booleans, here's the reason https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Object-operator_Object.html
Probably used the the incorrect terminology, mb
in languages with more built-in boolean coersion this is a more common mistake and/or idiom, like in c/c++ or js
Yeah in hindsight it makes sense, but it's definitely a mistake
So if you boil it down, it's basically just "if (pinnedQuest != null)" right?
that looks so wrong π
ScriptableObject whatEv = null;
if (whatEv = new ScriptableObject())
return;
it also assigns quest
yeah lol
oh yeah you're right
so it's more like if ((quest = pinnedQuest) != null)
for the sake of the if statement the quest doesn't matter but yeah important to keep in mind
i guess this idiom wouldn't be used in c# at all since c# already has the try/out idiom
not like it's used much in other languages since it's hard to read lol
Hello !
Small question about the Invoke, when i put other value as "1" for timeBeforeSpawn, it does not work. Like "Activated()" is never called at all !
Do you have any idea why ? Thank you guys ! The "timeForSpawn" is a parameter
And here, only the first 3 are spawned
Show the logs (uncollapsed)
Place a log before invoke and see if it even makes it there
I think you should ping him because i feel like he didn't see your message
Ahah i did
im looking on the documentation about "log"
But yeah don't hesitate to ping me π
I understood my error π
I thought that "120" was "120 frame" and so "2 seconds"
but it's actually 120 seconds
so the error is fixed, thanks π
Hey I need to get some opinions on this character controller, anything to note on this.
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour
{
[Tooltip("Forward/back speed (units/sec).")]
public float speed = 1.89f;
[Tooltip("Turn speed (degree/sec).")]
public float rotationSpeed = 89.0f;
private Rigidbody rb;
private void Start ()
{
rb = GetComponent<Rigidbody>();
if (rb == null) Debug.LogWarning("PlayerController needs a Rigidbody.");
}
private void FixedUpdate()
{
Vector2 moveInput = Vector2.zero;
// Foreward/backward for the player
if (Keyboard.current.wKey.isPressed || Keyboard.current.upArrowKey.isPressed) moveInput.y = 1f;
if (Keyboard.current.sKey.isPressed || Keyboard.current.downArrowKey.isPressed) moveInput.y = -1f;
// Left/right (rotation) for the player
if (Keyboard.current.aKey.isPressed || Keyboard.current.leftArrowKey.isPressed) moveInput.x = -1f;
if (Keyboard.current.dKey.isPressed || Keyboard.current.rightArrowKey.isPressed) moveInput.x = 1f;
// Move is facing direction for our player
Vector3 movement = transform.forward * moveInput.y * speed * Time.fixedDeltaTime;
rb.MovePosition(rb.position + movement);
// Y-axis rotation (invert when going backwards.) For the Y Axis rotation of our player
float turnDirection = moveInput.x;
if (moveInput.y < 0)
turnDirection = -turnDirection;
float turn = turnDirection * rotationSpeed * Time.fixedDeltaTime;
Quaternion turnRotation = Quaternion.Euler(0f, turn, 0f);
rb.MoveRotation(rb.rotation * turnRotation);
}
}
!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.
That's what I'm trying to do.
Clearly you did not. you neither used a paste website nor did you use the ` pattern to paste it here.
Hold on, I think I did but it just didn't show it.
I used one of the sites to do this.
then you have to paste the link here, not the code...
OK I'll send the link
a powerful website for storing and sharing text and code snippets. completely free and open source.
I actually tried to follow the instructions of a character controller for my game, and actually tried to write it all down myself.
I mean, there is not much happening right now. But one thing you should change is your input detection happening in fixed update. Physicsi in fixed, but input in update
Do you got specific questions about it?
I'm trying to make a Resident Evil 2 remake-type game. Would there need to be any changes to the character controller for this to happen?
MovePosition and MoveRotation should only be used with kinematic rigidbodies, which I assume the player is not. It should use forces or set the velocity instead
and checking individual keys kinda defeats the point of using the new input system
you could use composite axes here to handle the inputs more cleanly yeah
Imagening playing with a controller instead of keyboard. So yeh, you should tie into the inpt system correctly with actions performed and input schemes to cover those scenarious
Ok, thanks, I'll try to input those into the new input system. Lol, I kind of sound cheesy with that line.
this is fine for isPressed checks.
yeh, but not recommended especially when not knowing the difference. So why not get into the habit of putting inputs in update upfront
fair enough
Good evening, I need help with a transition. I'm making a small walking simulator game. My question is about the transition between scenes.
In scene 1, the player is in a forest and enters a church (scene 2).
From scene 2, when the player opens the door to exit, he finds himself directly in another forest (scene 3). Is there a way to make the transition between scenes 2 and 3 happen without "teleporting" the player into scene 3? What I mean is, is there a way to load scene 3 IN scene 2 (or vice versa) so that everything looks clean?
might be additive scene loading you're after?
yep, async additive scene loading
im new to unity so i was just tring thing
While you're in scene 1 (maybe when you get near the church) you can start asynchronously and addtively loading scene 2.
Once inside, you can async and additively start loading scene 3. You can meanwhile start asynchronously unloading scene 1
(assuming the player cannot go back to scene 1)
okay thanks, I'll try and let you know
I am officially moving in the direction of getting to advanced C# and wondering if I should stop or not. My current career feels unstable and I think it's time to move on. I find myself liking learning about programming and every 6 hour study session goes by in a breeze and I feel I'm acquiring things fast. But I'm worried that programming will soon be an obsolete skill. Like learning the mechanical engine of a 1940s car. I feel like AI is advancing too fast to really know what industries it will take over and what will be safe. Only best educated guesses like nurses likely being more safe than data analysts. Problem is I have not found one of those "safe" careers that seem interesting yet. Thoughts? Also please don't do cope answers like "Ai still makes script errors, it's safe". It seems like a super short sighted opinion and definitely not something to base a career off of. But also in such modern times, does it even make sense to plan at all......
Not sure if this is the right room for the question
If you enjoy it, never stop.
Programming will never go away, but it will continue to evolve. Very few people these days know how to do low level programming.
given that you're describing literally any counterargument as "cope answers", I think you've already made up your mind
If "not yet" is the only counter argument then yea I guess it falls under my definition of a cope answer.
Thanks for your opinion. I thought c# was a high level language though
.. yes it is..
ai isn't going to replace actual skill, if people stop actually practicing then AI just would stop improving from lack of original training data
I suppose that last bit required too much extra thought to understand.
It used to be that there was only low level programming, then came the next languages and now there are less people who know low level.. programming evolved
I don't know what "real programming" is but doing things in unity I am just describing the behaviour what I want most of the time instead
I think it's called scripting
That's basically the same as telling LLM what you want isn't it?
there was that joke that AI would replace programmers at the point where people who they work for would know what they want
The actual typing of the code part was never the bottleneck in software engineering
Well
maybe it was in the punchcard days
there was a time that our modern "computers" replaced the job of "computers". math skills aren't any less useful today.
Interesting thought. But models can be curated/fine tuned so I imagine there will be a few programming brainiacs out there that assure program AI doesn't start being dimished into slop from being too abstracted from the original intention written code
well, they are less valued
not sure where you're getting that from
to think of it maybe not, maybe it's now needed for more complex things
by needed and valued I mean money you get from just doing that
you still get money doing math
I'll go tell my account he's charging too much
I mean being able to do calculations now is less useful because u can use apps for that
lol no
U mean a calculator?
like that
thinking is faster than writing and reading into a physical device
The abacus really gutted the maths industry
there is also that thing that
accounting apps
and see how that destroyed accounting, definitely a dead industry these days!
Do you think "good at math" means you can just do rote computations of basic math problems?
the point is problem solving, not just raw numbers
I meant something like that starting this
calculator can't save you if you can't even figure out which numbers to use
I am saying that it's "less valued" not like obsolete
You're going to need strong mber theory. The ability to fully internalize spatial geometry. Intuit units and conversions, come up with elegant equations to solve practical problems
you get less money out of same math? I assume that
that comparison doesn't really make sense
Math is not solving equations.
You're on a computer. The device literally named for doing these things
there is a good chance we talk about different things
Game development is going to require a lot of high-level mathematical concepts
the kinds where the test says "You can use a calculator, computer, and open-book" and then you end up using none of them because they literally do not help you solve the problems
like if you could get money from doing annoying job of calculating stuff
less valued now because you can use a device now you should learn something else, more
that still wrong?
Hello, so i have a very weird issue that suddenly, some prefab of mine seems to be very stretched. I have to put the "scale" value to "0.02 1 1" to fix it but until now everything only ad (1, 1, 1), the root, the folder, the subfolder...
So that's new. Is this a common issue ? And do you know how i can fix it please ? Thanks !
β οΈ NOTHING and i've verified inside the "OrangeDragon" folder have a different scale from "(1, 1, 1)"
Check its parent objects!
your 'lossy scale' is the product of your own scale, plus the scales (and rotations) of all of your parents
"Annoying calculating stuff" hasn't been the actual problem to solve in nearly a hundred years
Notably, if you dragged this prefab directly into the hierarchy, its local scale will be untouched (so it'll stay at [1,1,1])
what kind of renderer is it? And yeah check the parent objects all the way up the line
it won't rescale itself, even if its parent has some wacky scale
Stupid damn triggers !
This was the issue, thank you !!
I try to avoid parenting objects to anything with a non-uniform scale
It causes headaches
So instead I might do this
- Checkpoint
- Trigger (non uniform scale)
- Whatever (has a renderer on it)
if you wanna see something wild, rotate the OrangeDragon object
it'll skew and deform
wdym
there were people doing that?
now people do more high level calculations where low level stuff is obsolete, something like that I am trying to say
those folks with slide rules
We've had devices that can handle the rote computation of tasks for a very long time. "Computer" used to be a job rather than a device, and was usually done by low-skill laborers because it was just plugging numbers into devices that did math that were a lot more annoying to use, but just as effective.
that I didn't knew how it works
I thought they were ugh
mathing?
Idk
Idk if i am dumb but i am trying to make the cam follow a cube right, Its giving me this error. Code aswell
you need to assign the player variable in the inspector
like it says
wdym
do you know what the inspector is?
Yes
so open it for the object with your script on it
and assign the player variable there
Add the FollowPlayer code onto the cube
what?
You already have the script on your camera, right?
Yea
sorry i am really new
so select your camera
look at the inspector
and assign the player variable there
Right now it probably says "None (Transform)"
you need to assign the player object in that field so it knows what to follow
how do i fix this issue in the essential pathway? it was fine till the publishing part
this is a code channel
!ide
If your IDE is not autocompleting code or underlining errors, please configure it.
Select one:
β’
Visual Studio (Installed via Unity Hub)
β’
Visual Studio (Installed manually)
β’
VS Code
β’
JetBrains Rider
β’ :question: Other/None
@dense basin
inb4 they tel you to shut up because that's what they were telling everyone who was attempting to help with that yesterday
also they were muted earlier
Eh maybe, I've been translating with Claude into Turkish which seems to help.
Crazy what you can do nowadays lol
this was in unity but i found a work-around
message wasnt for you ~_~
it definetly looks like it was for me
or am i missing something
there's a ping right under the bot message
they pinged who it was for right under and if you check the persons chat history they had just that problem (ide not being configured)
and a lot of times people will also just run bot commands for themselves
this too
i didn't see the pinged guy having a problem
i'm having a problem with opening this one specific door even though it works fine for the other doors
use mp4 to embed the video in discord
dang it
mp4 now
instead of wiggling your mouse around, you should describe the problem with your words, and share the relevant code correctly
so i use this one script the essential pathway provided me and for some reason, that ONE door won't open
even though the trigger box is in the correct place, the script and the box collider is correctly placed
no nvm i forgot the animator
sorry
Does anyone have any Resources on how to make Tilesets I can interact With?
Like if I press a Button while My Player RigidBody is over a specific Tile set it changes it into something else?
could you be more specific? are you making a 2d or a 3d game? why do you want to add this?
since tiles aren't gameobjects you need to work off their coordinate / position in the tilemap
Yeah 2D
finally completed the essential pathway
Look at the Tilemap API:
https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Tilemaps.Tilemap.html
These will be of interest:
WorldToCell
CellToWorld
GetTile
SetTile
!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.
learning to use these will make your life much easier
i tried to do the position math myself for a bit
and then i realized that i don't have to!
can someone tell me the best way to learn how to make fps games?
yeah but i was asking if you guys have recommended tutorials that i can watch
!learn
:teacher: Unity Learn β
Over 750 hours of free live and on-demand learning content for all levels of experience!
Hello, im trying to return a list, but it doesn't work. Unity tell me that "Convert Loot into Loot" which i don't really understand..
My goal is to give my enemies a wide variety of possible things to drop on death with each having a % of drop, and return a list that will say "drop all of them !"
Thank for those willing to help
π 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.
these two Type's are not the same
Ah, it's pretty self explanatory then. Thank you ! Both errors got fixed !
yes, as the function was expecting to return a list of loot π
one second if you dont mind @errant breach
What is that return in the first loop intended for?
That's what im wondering too π does it look like a mistake ?
It does indeed π
Are you not the one who wrote it? π
Im actually looking at a tutorial to make a lootTable, but i want my enemies to be able to drop multiple things instead of one (like in the tutorial).
The man in the video told to "add that return if you want to make a list of items to drop" so i did it without actually understanding why xd
I know, following tutorials blindly is not the good way to go but.. I gotta learn !
tf it mean by "if lucky" is there just a chance that the code says no i dont want to execute this
-# oh wait this aint your code so you probably wouldn't know
You made me laught anyway π
hmm discord having some problems (forgive me for talking about non code)
if you plan to drop the whole loot table (after the chance) why make a new list instead of just returning possibleItems?
Right ok, couple things to say
Firstly, return ends the function (by returning something), as in if that return runs that function is done. this means with that current code your never going to get anything more than 1 loot in that returned list (since you return after adding)
Secondly, that randomly rolled number is being used for every check in your lootList loop, you probably want to roll that per item right?
Thirdly and this isn't a problem or related to problems but just a random tip, in your InstantiateLoot() function, if you have the prefab via a reference to a component (which you do here via your reference to Loot) you can get a reference to the instansiated component directly, eg.
GameObject myInstance = Instansiate(myPrefab);
Loot myLootInstance = myInstance.GetComponent<Loot>();
can just be
Loot myLootInstance = Instansiate(myPrefab);
Hi! So I don't know why but I am trying to make an area in my secene that detects the player and reduces their health but I can't seem to make the area detect collisions. Does anyone know why that could be? 1. First picture is area 2, Second picutre is the player 3. picture is the code
That's right, i could do that π
and i will !
WOA ! That is a very productive return, thank you for that !
You know what ? I'll stop Unity today, made to much code and i feel like i can't even think anymore (im struggling just to find my words π )
Tommorow i'll work on it and i will check everything you said ! Again, thank you, and have a great day / night ! :D
Appears like it should work at first glance.
Btw its bad design to modify the player health so directly outside the PlayerData class
OH you arent using the 2D function thats why its not working!
https://unity.huh.how/physics-messages/trigger-messages-2d
OHHHHH
Yeah, omg, i was breaking my head for like 15 minutes
Thankss
but my comment about design still stands
your player health should be read only and you should use a function to apply damage
yeah no fair enough, normally I would do another class that modifies it but I just kind of dont want to do it rn, is for a level design project for class and the programming is not a focus
But thank you though
Well function
No your PlayerData class would have the function to modify health
It should "own" and manage it
also thats a unsafe assignment/assumption on the getcomponent, you should use a trygetcomponent eg.
if (other.TryGetComponent(out PlayerData result))
{
playerData = result;
StartCoroutine();
}
ohhh I totally hadn't thought about this, true
Thanks! I will have it in mind
and not to hit you with another one but you probably wanna set damageCoroutine to the coroutine your running, right?
oh huh? I kind of forget how coroutines work
StartCoroutine() returns a Coroutine. your StopDamage() function won't work because you never assign a Coroutine to damageCoroutine
I think if(damageCoroutine != null) is not a good way to check if a coroutine is running anyway. It may have ended but that reference would not magically become null
If you add a damageCoroutine = null when stopping it then it makes sense
(But yeah none of this matters if you never assign to it, as Batby said above)
Hello, how can i configure VIsual studio Community Edition 2026 so that the compiler show the error ? Thank you !
!ide
If your IDE is not autocompleting code or underlining errors, please configure it.
Select one:
β’
Visual Studio (Installed via Unity Hub)
β’
Visual Studio (Installed manually)
β’
VS Code
β’
JetBrains Rider
β’ :question: Other/None
Hello im going to try explain this best I can.
I have a script on a weapon that drags another object(an orb) along the x and y axis only, the orb has a tag CanDrag.
I added SmoothDamp which delays the drag when I want no delay
The problem im having is the orb is not being dragged smoothly. I dont want smoothdamp since it causes lag and even with it low, theres still bounce or jitter. I want to drag the orb without it bouncing or jittering left and right
I am so lost any help is appreciated!
little context, the orb is the purple circle. Im in unity 3D. I want to drag it to the red(finish line).
are you using physics?
it seems like you are
in which case, you should not be modifying the transform, as that causes physics desyncs - you would move with forces instead
That makes sense, how would I go about moving it with forces if im dragging it? If you dont mind
I mean if you don't want to use SmoothDamp then just... don't use it? Replace it with Vector3 newPosition = targetPosition; instead
Seems like collision checks are done manually so pure physics based movement might be unnecessary
Hey folks, I have a question related to fbx usage.
I had a code to create a sort of blinking effect that worked on my capsule by enabling and disabling the mesh renderer, but when I changed the model for a fbx (from kenney), I had the issue that there is no mesh renderers. The prefab is just a transform and I have no idea how I can have the effect I wanted now
Hello everyone,
I've created a loot system, and im being hit with errors i don't understand.
Here how it work : I give a list of possible drops to an enemy. When he dies, some items get added to a list, and then instantiated (dropped)
But when my enemy dies and play :
GetComponent<LootBag>().InstantiateLoot(transform.position);
Im getting hitted with the error :
ArgumentException: GetComponent requires that the requested component 'Loot' derives from MonoBehaviour or Component or is an interface.
But it IS a MonoBehaviour right ? So, if anyone can help, i would be glad.
Thank you !
And, by the way, the print return :
System.Collections.Generic.List 1[Loot]
So i guess i did something wrong..
!code as text, not screenshots
π 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.
but Loot is not MonoBehaviour, it's a ScriptableObject
You have to GetComponent the component that has a reference to the loot scriptableobject
Aah, i see, with something like :
GetComponent<LootBag>().InstantiateLoot(transform.position);
In that case ?
I don't know what you're trying to do exactly but uh, maybe?
Holy jesus bad idea
Well if you literally put that in then yes what did you expect it to do
So essentially, i create a list with all the object that will drop.
it work by giving every ressources a % percentage, and then taking a random value between 0 and 100. If the value is good then the ressource get added to the droplist
And then, i want to instantiate every ressources that got in the list. By taking the "Loot Object" (which is a GameObject)
Buuuut im struggling to π
For the code, here is it :
Ok, but you already instantiate the prefab with Instantiate(droppedItemPrefab) What is the line after that supposed to do?
I guess, the LootPrefab is like a wrapper to instantiate and feed it with the data of the SO to then spawn the actual object. But you might have one unnecessary layer here, as you can just grab your info from your list and directly instantiate the item_shoot in this case. Unless your wrapper object needs to manage the loaded asset in a specific way
It does look like a mistake of mine...
Im going to be straight because i don't to lose your time, i have no idea what "LootPrefab" is supposed to be. I just followed a tutorial for a 2d game while is 3d and tried to make it compatible. LootPrefab look like a random GameObject with nothing particular on it so i dont understand anything
blindly following a tutorial might not be the best approach here. But since the system is not super complex, you can now take your time, reread and rethink the setup and see, what makes sense for you or not.
Okay i did understand : in the tutorial, "LootPrefab" is a placeholder for an image, so i don't even need it here
Yes, you are right, but we only have 2 days left and still a lot to do, so im using a lot of tutorials to gain time..
I will try, but exceptionnally, if the error is obvious i would be glad if you can give me some minutes to find it and, if i don't manage to do it, to tell me what's wrong. π
I mean, the solution to your initial problem is written up there, right? Dont instantiate that unneeded lootprefab, instantite your prefab from your scriptable object.
Yes, it is. So as it is a list, i need to get the GameObject inside the scriptable object LootObject...
But now, im blocked because i don't know how to access the right scriptable object in my list.. π
...
So here's what i've done. Am i in the good path ?
Or maybe i need a GetComponent..
item is already the ScriptableObject. Then you can access the lootObject field normally: item.lootObject
Yes i added it π just wanted to show how far i went
It does work now ! Thank you guys for the help :) !
I have a weird issue... I have a serialized field array, with some values in it, but when I start the game, the array becomes empty... I do not empty it in code mind you
how about adding some code here
I resolved my issue. I just deleted the array values in the inspector and re-added them and it works now. Weird
Now I have an issue with items in lists that I want to remove but they aren't removed.... issue is I destroy them so it crashes
foreach (SegmentController segment in _instanciatedSegments)
{
segment.transform.position += Vector3.back * Time.deltaTime * _speed;
if (segment.transform.position.z < _destroyPositionZ)
{
_instanciatedSegments.Remove(segment);
Destroy(segment.gameObject);
AddNewSegment();
}
}
Apparently the item I want to remove stays in the list
Ok, thanks Iβll move my post.
You are probably getting the error of changing the list while accessing it?
I think I'll leave it for tomorrow, I've been working for 5 hours straight and I'm hella hungry
!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.
hey guys, what's System.Collections ?
i'm watching a tutorial for first person movement and his script is using System.Collections and System.Collections.Generic
those are 2 namespaces
he didn't explain it and reddit is useless nowadays
before watching that tutorial i would suggest you watch a C# language tutorial
i know c#
or well a lesson
have you tried google
the top results were confusing
that's the only result on the first page to me. idk why google's been doing that...
but yeah that's already a pretty adequate summary right there
i just want to know what purpose does system.collections serve
System.Collections and System.Collections.Generic are in the monobehaviour script template. it's not necessarily used in the tutorial script.
maybe it was removed in a later template? i haven't really used unity 6 so i wouldn't know
maybe the tutorial was using Lists?
It's a part of dotnet that gives you access to collections (implied through naming convention - example: List)
https://learn.microsoft.com/en-us/dotnet/api/system.collections?view=net-10.0
yeah the tutorial created it and it automatically popped up
or maybe the tutorial was just using a version of unity that had those namespaces in the default script template
occam's razor, man
i wonder why they were using it but then removed it
a lot of scripts won't need to use them
Hello guys ! Im trying to make a Powerup move toward the player...
- The print
print("tentative d'aller vers le joueur");is executed, so all the condition are meant ! - But the gameObject doesn't even move at all !
The Powerup has one transform and one gameObject:
MyTransformis placed in the editor. All the prefab have one (i've checked)
PlayerGameObjectis took with aplayerGameObject = GameObject.FindGameObjectWithTag("Player");
It work, because it found it.
Do someone have an idea of why it doesn't work ? Thank you guys !
!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.
Oh alright π sorry
- the parameters are the wrong way around, you're making it move from the player towards its current position
- you have to call MoveTowards every frame, not just once
Seeing the whole thing, it is called every frame but it's moving to the wrong direction and too fast. Try this:
myTransform.transform.position = Vector3.MoveTowards(myTransform.position, playerGameObject.transform.position, 3 * Time.deltaTime);
also should be Update instead of FixedUpdate
You find all the problem thank you ! Completly forgot about deltaTime.
And thank for the suggestion, but wont Update.. Update everything at a unreasonnable speed ? That's what i understood..
not if you use deltaTime correctly
But like all the script will be executed a crazy amount of time per second is that right ?
Like the script that check if they are dead, ...
Yes, but computers are also crazy fast so it doesn't matter
And you shouldn't be constantly checking if something is dead, only when something happens that might cause them to die (e.g. taking damage)
I tried but my player can like shoot 10 bullets at the same time so my ennemies where dying 10 times π
You did it wrong then
On trigger enter
Remove health
if health < 0
kill (set "Died" to true and run an animation)
π
this happens regardless
But i do trust you when you tell me that i made it worng
using Spell.ECS.Component;
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
namespace Spell.ECS.Systems
{
[BurstCompile]
public partial struct ProjectileSpawnSystem : ISystem
{
public void OnUpdate(ref SystemState state)
{
var ecbSingleton = SystemAPI.GetSingleton<BeginSimulationEntityCommandBufferSystem.Singleton>();
var ecb = ecbSingleton.CreateCommandBuffer(state.WorldUnmanaged);
foreach (var (request, entity)
in SystemAPI.Query<RefRO<ProjectileSpawnRequest>>()
.WithEntityAccess())
{
Entity projectile = ecb.CreateEntity();
ecb.AddComponent(projectile, new LocalTransform
{
Position = request.ValueRO.Position,
Rotation = quaternion.identity,
Scale = 1f
});
ecb.Instantiate(projectile);
}
}
}
}
using Common.Singleton;
using Spell.ECS.Component;
using Unity.Entities;
using UnityEngine;
namespace Spell.ECS
{
public class ProjectileManagerECS : RegulatorSingleton<ProjectileManagerECS>
{
public EntityManager entityManager;
protected override void Awake()
{
base.Awake();
this.entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
}
public void SpawnProjectile(SpellContext context)
{
if (!context.ShouldSpawnProjectile)
return;
Entity requestEntity = instance.entityManager.CreateEntity(
typeof(ProjectileSpawnRequest));
this.entityManager.SetComponentData(requestEntity,
context.SpawnRequest);
}
}
}
why entity not spawning in world?
Can I ask about DOTween here? I'm trying to use DoShake but its 1.0 default strength is too much and any strength value under 0.5 doesn't perform the shake at all.
Does anybody seem to have the problem of references breaking while doing a checkout from one branch to another branch (GIT) in Unity?
I had this issue on some of my projects. I had this experimental branch, where I made so much progress and was curious to see how the old main branch was and I switched. This broke so many references and introduced a lot of bugs, which was hard to solve.
references are stored in scene/asset files and their sources are stored in meta files (as a rule of thumb), make sure you're keeping them consistent
moving meta files around along with their corresponding assets
I also track the metafiles as well
This feels very scary. Like moving from the latest commit to a very old commit 10-20 nodes back and breaking it all.
Is there a solution for this?
Maybe worktrees could help?
well you'd have to first figure out where the mismatches came from
Are you looking through what changes are happening?
I don't think I'm getting mismatches.
The references in Unity seems to break(most of the public fields) and even if I fix I got few errors, which I don't remember.
Are you seeing unexpected ID changes happening in diffs?
Long number changes in your commits. Some of them have "ID" on the same line.
hey, i'm making a movement script but this error pops up while visual studio says there is no problem
NullReferenceException: Object reference not set to an instance of an object
PlayerInput+OnFootActions.Enable () (at Assets/Input/PlayerInput.cs:1310)
InputManager.OnEnable () (at Assets/Scripts/InputManager.cs:28)
why does my sprite go through the floor sometimes and the hitboxes glitch? what can i do to fix it (the hitboxes of the sprite and floor are correct, and yes i tagged to floor if you want to ask that)
you should use physics based movement instead of translate
how?
that is up to you, you are using linearvelocity there for your jump mechanism. you could use same for moving the player too
okay ill figure it out ig thanks
onenable is running before you doing = new() on start
you should probably use Awake or OnEnable itself
Haven't really used it but maybe the object has something else modifying the ttansform/fighting with it? What scripts does it have, animator, rigidbody?
with this script, i use lineair velocity but when im in the air and i move left or right i basicly dont have any gravity down anymore and i also cant jump when im moving left or right, i also dont want the movement to fade out, just stop instantly
you're overriding gravity
how
actually yea only apply it to X as osmal said
Character rigidbody movement is actually tricky but try using linearVelocityX to only modify x vel
The first two linearVelocity = lines change the Y velocity to zero too
Sort of right
what should i do with the y velocity then?
Keep the previous y velocity by not touching it
im confused i dont know what to do anymore
You have three lines that modify linearVelocity
The first two should be modifying linearVelocityX (left right)
The third one should modifiy linearVelocityY (up down)
And instead of Vector2.left you need to use a single float -1 etc.
2Drigidbody lets you individually change X or Y
i fixed it but i dont want to have to hold w to jump just want to press it, but when i use getkey the glitch appears and when i do getkeydown it doesnt but i have to hold it
how does the new code look like?
iΒ΄d use addforce for the jumping, it makes most sense
wait i changed it what
why did it change back
i accedently did ctrl z
whoops
it still phases through the floor and i still drag to the right or left after i released π
not in the air anymore tho
when you let go you have nothing resetting linearVelocity
thats why its often better to just capture GetAxis("Horizontal") and pass that directly to linearVelocityX
without GetKey/LeftRight
im basicly back to the start cuz you said getaxis (did raw cuz better for my thing) but it still phases through the ground and i dont know how to fix it:
void Update()
{
float input = Input.GetAxisRaw("Horizontal");
movement.x = input * speed *Time.deltaTime;
transform.Translate(movement);
if (Input.GetKeyDown(KeyCode.W) && jumpcount > 0)
{
myRigidbody.linearVelocityY = jumpForce;
jumpcount -= 1;
}
}
no one said to use translate tho
you can just apply it to velocityX
without the deltaTime
idk what to do else and i had to make it move
i mean i dont know how the code looks like
take a moment to think about what to type in
today is my 1 day anniversiry of learning c#
i have NO clue on what to do
ask freaking chatgpt
no front
:/
what is front
no
π
perhaps learn and start simpler then
yes
don't suggest stupid things in a beginner coding channel
chatgpt helped me so freakin much
i watched 1 vid about flappy bird coding and it practicly got me here
it overcomplicates stuff for no reason
Do not suggest people do things that will make their life significantly harder
give me a reason why its stupid
thats not how we learn
also flags things that arent wrong
the book is too long
but how do we
only on other ai models bud on chatgpt its not. perhaps u can tell the ai to make it short
ai is not a book?
Surprise, the AI shill can't read
ok just tell me how to not phase through the ground guys
you start small..
and maybe on how i do learn how to code
ai helped me more than unity tutorials. like i use ai and a german unity learning book
Usually, by reading up on the concepts and putting them together in experimental ways instead of just copying code from a tutorial
To think and learn as programmer you must practice as programmer, not search easy ways.
besides the code being wrong you haven't even shown the actual setup you have
translate is the first thing to not use because it literally teleports and ignores all colliders so thats first
but how do i do it then?
you don't just get to a solution right away
You'll want to use physics to move, which will respect colliders
as said you use the rigidbody methods.
that helps nothing
look how happy he is
cant even see the colliders n shit
one above is is trigger and bottom is with colision
ts the floor btw
to reset jumps
why do you need a trigger on the floor for that..
Hello! I'm experienced with code but am new to game development, what are some general important steps/information that I need to know starting out to make my first game?
it will not scale well at all
!learn
:teacher: Unity Learn β
Over 750 hours of free live and on-demand learning content for all levels of experience!
i dont know i did it and it worked and im not touching it
bro just tell me how to not make stuff phase through other stuff
Is that a command I can run?
like 20 people told me to use somehting else but i dont know how to use the thing
Maybe you shouldn't use the collider type that lets things phase through it
i have 1 for trigger and 1 for colision...
when i double jump there isnt a frame to touch the ground so it just phases right through the ground
I figured it out. The function has 2 bool parameters with default values and I thought I was setting one of them but in fact I was setting the other which caysed that behaviour. Thanks for the reply!
did you click the link ?
Use Rigidbody instead?
i fixed it with ai cuz you guys dont want to help
Oh it just appeared for me
come back when your older please and thanks
the multiple people spending an hour talking to you for free clearly are here to help you
don't blame them because your struggling
who wants to hear "tell me how" every fucking sentence
shit gets annoying
let "AI" solve whatever, don't come back with broken AI code because you have no idea what kind of abomination it generated & 0 understanding on any of it
looks like* they found exactly who
AI
because critical thinking is now irrelevant
i put off for using ai for it for like 15 minutes to wait help all i got is "figure it out and think"(for my FINAL problem, not the other 2 that did get helped by people)
sad but true. People want shortcut to knowledge and it does the opposite effect
i dont copy and move on i actually try to learn the code that i got before moving on
ah just like you learned the method of rigidbody we been saying to use for the past hour?
yes a true learner
yes but the final problem yall didnt help
and yes i did use ridgidbody for the problem
i had to make a new vector 2 and i didnt know how to
or atleast thats what worked
if this is your first day of c# this conversation is the equivilent of learning french by picking up a french book and asking people what a word on a random page means
you need to actually consume educational resources made for beginners to learn what your actually doing
c# is a whole language that you have to learn, like how you learn english and/or your native language as a kid
nowhere did you need doing that with what we suggested but you keep thinking that
yea i know but i suck at learning only so i try to actually make it fun but that makes it sometimes hard so i ask for help, sometimes it works sometimes it doesnt
do as you wish, no one is stopping you. As I said we don't help with AI code, when you get stuck again cause you have no idea what the code even does then what
you suck at learning so you choose to use ai
i don't think this is a productive comment
I think it is
no you guys didnt help me so i used ai
But i also highly doubt you suck at learning
more so you dont have the patience for it
yes
thats a seperate issue
you probably can't make games until you resolve that
you can't shortcut your way to knowledge no matter how much the AI sloppers tell you
its something im born with? just let me have fun
experience comes with learning and patience at doing it until it works by your own practice
no one is born with it
ive never heard of "impatience" as a medical condition
ive never had patience tho
its entirely enviromental, and something you have to work on yourself
patience isnt a quantifiable thing
you weren't taught to have patience
hows that my fault
As harsh as it sounds, its a symptom of immaturity
who said it was
the reason i suck at patience cuz when i was younger i was smart and could learn a lot in 1 day
now i cnat
and have to get used to it
you gotta start to teach yourself patience
You have litterally the perfect place to start
in my point of life where i am right now thats not a priority thats in my mind at all
you were given the opprotunity to do
trust me i dont
πΏ
thats fine, just probably stay away from this channel then
what do you hope to accomplish in game dev without patience
you know what
i dont much care
im not a game dev
eh no need to steer this into offtopic land, let them cook , until the next thing breaks then they realize you can't shortcut through experience and knowledge and give up cause "me no patience" yada yada
im having fun and messing around
coding is fun tho
Im sure it is, its not fun trying to help people who dont want to be helped
not our problem
i want to be
coding requires patience.
if you have none, especially to learn. Find another place
you havent shown it
i just dont like it when i dont know how to do something and people say figure it out
too fucking bad you don't like when are told to "learn more" before doing more..
only person who said it was you lmao
be a grown up about it and actually take the advice where we all been there but we actually put some effort into starting from building basic knowledge
Guys, 3 vs 1
Not fair
Can you calm down?
Thank you for the input Norman
is this why you chose to send a popcorn emoji earlier, so you could high horse us?
Nah Norman has a point, dogpiling on someone is not cool. Yall are making the same points
this is a conversation, if anyone doesnt want to be a part of it, they can leave.
i said i did know how to do it btw
yes exactly.. code is precise
probably best for all to just drop it and move on to something else
nothing wrong with taking a moment to think what to type if that offends you too bad..
butyeah whatever im movin on.
thats like asking a child on how to make a rocket
he doesnt know how
then the child shouldn't make a rocket
hence the suggestions to learn chemestry before doing so ?
you know what i mean bro
you don't just start mixing shit and cause an explosion or poison yourself... you learn what each thing does
That had another meaning. If you think so, go ahead
let me give a better example
if a child is learning how to talk
you cant say "just talk"
you gotta learn how
It had the meaning that you found the conversation interesting before you decided to act supercilious
But besides, i think this conversation has lost all its value, ages ago
true
this is a moot point, either take the advice or don't
nav is just being an asshole and some mfs are siding with him
i had 3 problems
people thought about 2
and those worked
the third one nav became an absolute asshole
iambatby you count as 1 of the simps btw
norman and osmal are the actualy people that know how to help
osman and normal
What extension is needed for visual studio (not code) for intellisense, auto-complete, etc.
!vs
If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:
β’ Visual Studio (Installed via Unity Hub)
β’ Visual Studio (Installed manually)
none
You need Unity Workload in the VS Installer.
no extensions though
normal osman is the green goblin guy right
Lol close enough
nav you could have said either how or the line on how to do it and explain it so i can learn it, that would have helped
same with iambatby
im just making a point bro
Laides you're both pretty can we move on
im a man
If everything is working correctly for intellisense and such, should I expect something like "using UnityEngine.[stuff]" to autocomplete?
The libraries?
Yeah
Is it not?
You should get suggestions when you are writing code
Not at the moment, but I'm handling the installation process rn
i do not know why i am getting this error, i can clear it and the game runs fine. should i be worried? it started when i created a script.
if you guys want me to learn code, how do i genuinely learn it? i dont know how cuz no one told me
check the pins here for some resources
!learn
look at the pins
:teacher: Unity Learn β
Over 750 hours of free live and on-demand learning content for all levels of experience!
ah okay
Try restarting Unity, looks like the editor is having a rough day
thx
The pathways are for more unity oriented stuff
if you want to learn coding directly
theres a couple of resources pinned in this channel
okay thanks. i swear my computer has been making Unity bug out recently. it would take an hour to load a project once and it wouldnt even load after that
the learn lessons assumes you already have some C# knowledge
ended up reinstalling the whole enigine π
Did you update the editor recently?
That is probably the smarter thing to do
well probably 2 weeks ago
What unity version are you on?
6000.0.68f1
6.0.33f still rock solid π
Resetting editor layout and rebuilding library can work for these unity issues
Yeah, I use that, no major issues here
Wait is that 6000.3.3f or no
Besides tmp sending a few errors once or twice havent encountered any issues on 6.3
is there a "proper" way to upgrade the engine or do i have to just delete the old version, install a new version and then open my project in that new one?
I feel like TMP is always a bit buggy
Theres a dropdown to swap versions i believe
no 6.0
oh! thanks for telling me about that
use version control, only delete old version once you've confirmed you've safely upgraded
They added ai to 6.3??
whats version control? π
don't delete the old version yet lol, make sure you have the new one up and running first
yea. not sure if its a package or built in but I aint touchin it
a way to back up your project for one
its still package exclusive iirc
ah, my friend just said to use github for that
As long as its not forced idc
a git repo is a form of version control
ah okay got it
The editor has this AI button even if you don't have it installed β¨ π
version control software (vcs) is software to manage multiple versions of your code
versions in this case being different versions in both time and space
in time, as you develop, you have access to previous versions
in space, as you develop separate features, or multiple people work concurrently, you can merge your work together
Welp looks like im downgrading versions
wow that sounds nice
i should set it up
youre not missing out on much with 6.3 tbh
why is ai in everything now π
the bubble is yet to burst
It's obviously gross but not a whole reason to avoid the newer versions IMO :p
money
shareholders / investors
here's an example of the shenanigans you can get up to with vcs (4 people working concurrently)
thats so stupid π
what do they even see in AI
will somebody think of the board chairmen
investor money
Really looks like a metro/subway map
money
we can only pray the people responsible lose their jobs π
what kind of GUI is that?
have they not been on the internet in the past year ??
doesnt matter, money
that's from the official vscode extension
a less cropped screenshot would dox so not showing that π
oh really? I always had the extension but i never once looked at it lol
what is it just a replacement for github desktop then?
ive never really considered github desktop at all. i used it to start but once i realized how bad it is with stashes i ditched it for all but partial staging, and then i ditched it fully after learning add -p
it's another graphical git interface
but i still use the cli a lot
ive been meaning to switch to cli fully
cost cutting, not having to pay humans to do work and think its a catch all solution to everything.
Usualy crap
that's a pseudonym, but some of the other commits in that other example are under real names
Ah everyone run! chris codes in java
did you go to my github lmao
then we would have a bunch of unemployed people
now you're getting it
I have way too much time on my hands
why cant we just limit AI to be funny chatbots again and not all this crap
money
people require benefits, money, sleep, food etc.. machines you know work for free basically
so what the future is just all machines?
who knows
aside from power consumption but thats passed onto regular power consumers anyway
Hopefully openai dies in 2027
2026, you mean
Was about to say that XD
They have enough funding for this year but not 2027
why is this happening when its my turn to be an adult π π hopefully the bubble bursts by then
there's always a chance to get sued into the ground, however little
openai, owned by a guy named Alt-Man. Kojima you did it again.
The job market is fucked and ai is somehow half the reason
maybe yours or next generation will be the next john connors
(fyi it's pretty easy to get into other languages. the first language is by far the hardest)
isnt java just lesser version of c# π
Yea i know i just wanted to hate on java
though c# in particular has a lot of really nice conveniences
still shocked gdscript doesn't have multi dimensional arrays, i figured that was standard
haha nice catch
What are some good kinds of questions to ask here? Should I do some research on a problem before presenting it here, or is it ok to ask first and get a better understanding that way?
First try google and then come here
yes
Should I do some research on a problem before presenting it here,
Ok thanks!
most questions, especially ones asked here have been discussed before you will find all sorts of info
Oh ok I'll keep that in mind
I like using the discord search bar for similar issues before asking
ime a little less clear cut.
c# has structs, properties, operator overloading, tuples, nice tools/QoL, but java does also have some stuff c# lacks, like enum members, anonymous classes (specifically with inheritance), method references
don't really know what you're missing until you try to use it and it just doesn't exist lmao
it is a pretty (relatively) complex thing once you think about it, isn't it
I honestly wanted to pick it up for the sake of Android and do specific things that frameworks like MAUI still don't cover yet
but then Kotlin is there and thats another hurdle so I said F it then
yeahh. i was trying to help someone with a little tile based thing and they we're a complete beginner and showing them a 2d array vs the idea of an array that holds arrays is such a big gap in teaching
stride moment
I mean technically its just an array thats holding a bunch of arrays, no?
there's more to it than that
some languages distinguish between arrays of arrays and multidimensional arrays
An array of arrays is not ideal in c# anyway (array of pointers)
but i think this starts to go past beginner stuff
1D array treated as 2D array with index conversions = π
Figured out my intellisense issue. In the solution explorer for visual studio (not code), the c# assemblies were marked as unloaded. Handled that.
this might be clearer in c land
// array of arrays
int row1[3] = { ... };
int row2[3] = { ... };
int row3[3] = { ... };
int* matrix[3] = { row1, row2, row3 };
// ^ this is an array of pointers
// multidimensional array
int matrix[3][3] = { { ... }, { ... }, { ... } };
// ^ this is 9 consequtive integers. when subscripting the first dimension, you have to multiply by 12 (4 * 3, sizeof(int) * stride)
Never understood the difference between beginner and advanced here tbh, im over here asking what i thought would be a conplicated logic issue and then I see some other dude with a script i barely understand
Something tells me beginner is more frequented, so even advanced topics get asked here in hopes of getting them answered sooner
Programming is like that sometimes but getting over that initial hurdle is the important first step
I think people just dont like using the forum channels
Just a lot more efficient then?
well at the L1 caching level sure, i guess
and subject to compiler optimization, probably
but that's not really the point
multidimensional arrays are more complex in their memory representation
How is that more advantageous?
memory is stored more compact, and stored as it's used
and also an array of arrays has potential to have null pointers
with a multidimensional array it's just the one pointer
So higher efficiency with less moving parts in a nutshell
less work for the user (of the language), more work for the developer (of the language)
cpu like to grab big portions of ram to put into cache, cpu un happy when it have to keep going to ram π
cache fast cpu like only using cache so it can go zoom zoom
cpu like making one big shopping trip instead of many
ill stop now
Hello, after working in group, a sudden error appeared :
KeyNotFoundException: The given key '22' was not present in the dictionary. System.Collections.Generic.Dictionary2[TKey,TValue].get_Item (TKey key) (at <73ac12a12f9a4ebca156b41ddce95fbe>:0)`
The thing is that.. I didn't coded anything that uses "Dictionary" !
The error came from "TMP_Font Asset" which is something default i think...?
So.. If anyone know what could be the problem, i would be glad ! Is this a common unity error ? Thanks !
The error get send every seconds sadfully..
It's an error in the TextMeshPro code, not your fault
E: Well if it's your fault then the TMP error handling is still bad
I feel like ive seen this before on this server. It may be due to a duplicate font with the same name
Lol^
Ah :'(
Have you found the font asset that causes it?
Maybe when my friend pushed his version (Unity version control) it might have broke something
Yea its certainly possible someone made a change to trigger this bug
We only use the default one
I think reinstalling TMP properly might be a great idea
But i don't know how to do it without destroying everything
I don't know, after testing it, he's completly broken
The upper one is the "FallBack"
And it got me the error. Okay, that's definitly the one
That shouldnt be needed unless someone else thought they were smart duplicating it and changing its mode to dynamic
Id remove the duplicate and keep the main one. If you need that one can be changed to dynamic to gain new characters as its used
i haven't used unity's version control, can you not look at the changes in the push and see what tmp related was touched?
I deleted it, thank π hope it'll fix
Im new to it too π
make sure you update the tmp settings fallback font list now
Alright π thanks
can anyone help me, im fairly new to coding and trying to make a low poly buisness game like schedule 1 but cant seem to figure out how to get it all started, also if there is any easier apps for a low poly game please let me know
Hello, there is something i don't understand...
My player's bullet take the player's PlayerSpeed parameter. From the GameObject Player. But for some reason, the bullet only take the parameter from the Prefab Player, not the active player in the scene...
Here's the code of the PlayerProjectile
public PlayerShoot player;
void Start()
{
// Get the player's values
transform.Rotate(0, 1 * Time.deltaTime, 0);
projectileSpeed = player.projectileSpeed;
projectileDamage = player.projectileDamage;
lifeSpan = player.projectileLifeSpan;
print(player.projectileSpeed + player.projectileDamage + player.projectileLifeSpan);
Invoke(nameof(DestroySelf), lifeSpan);
}
If someone know why instead of taking the parameter of the active player, my bullet take the one from the prefab, it would greatly help. Thank you ! :)
Well how are you assigning player? Looks like you assigned it to the prefab
so naturally it comes from the prefab
I did ! But it will cause issue if i don't ? I always thought it was the good way to do !
It's a good way to do things if you want a reference to a prefab, sure
like if i give the active player and then change scene and put a new player... π€
Since this is likely a projectile you're instantiating at runtime, you will need to pass the reference to the runtime player object at runtime after you create it.
e.g, in the script that spawns projectiles, something like this:
public class Player : MonoBehaviour {
public Projectile projectilePrefab;
void Shoow() {
Projectile spawnedProjectile = Instantiate(projectilePrefab, ...);
spawnedProjectile.player = this;
}
}```
are there any easier apps that i can use to make a low poly buisness themed game like schedule 1
this is code channel..
Alright, thank you for the explanations !
how do i control cinemachine virtual camera distance with scroll wheel? i want to zoom in and out
it depends which ocmponent you're using for the position of it
whatever that component is, modify its follow distance in your code
i want to modify camera distance (the bottom value)
reference the component and find it through the properties
https://docs.unity3d.com/Packages/com.unity.cinemachine@2.10/api/Cinemachine.Cinemachine3rdPersonFollow.html#Cinemachine_Cinemachine3rdPersonFollow_CameraDistance
I was trying yesterday but still a little lost, Hello im going to try explain this best I can.
I have a script on a weapon that drags another object(an orb) along the x and y axis only, the orb has a tag CanDrag.
I added SmoothDamp which delays the drag when I want no delay
The problem im having is the orb is not being dragged smoothly. I dont want smoothdamp since it causes lag and even with it low, theres still bounce or jitter. I want to drag the orb without it bouncing or jittering left and right. I think raycast is the problem since I tried with force before this script im sending unless I did it wrong. I also think this since my other weapon raycast are jittery
I am so lost any help is appreciated!
https://pastecode.dev/s/70pajo0n
little context, the orb is the purple circle. Im in unity 3D. I want to drag it to the red(finish line).
does the object have a Rigidbody?
yes but doesnt need one, Ill go with wtvr fixes the jitter
if it doesn't need one definitely remove it
okay
You should never move a Rigidbody by modifying the Transform like this
okay but I really think its my raycast or camera. I did a debug and the raycast was super jittery over small movement unless its always like that
raycasts themselves are not "jittery" and cannot be "jittery"
collider positions do not update except during the physics update though
so if you're expecting to move an object and then have raycasts immediately see that movement within the same frame, that won't work
but the raycast isn't really relevant to the regular jittery movement right?
That's just for detecting walls?
okay
definitely start by removing the SmoothDamp and just get it working with e.g. MoveTowards to start
e.g.
Vector3 newPosition = Vector3.MoveTowards(
currentObject.transform.position,
targetPosition,
Time.deltaTime * speed
);```
im just trying to move the orb in 3d on the x and y axis. when I drag it down slowly it goes left and right really fast
ill try this out
dragging this down slow it bounces left and right reallyyy fast
i cant figure out why though
If the position is changing on the x axis while you're simply dragging dowwn on the y axis, you've likely got something else adjusting it's position
https://pastecode.dev/s/y7uc8hlh
heres the script if youd like to take a look. its the only script moving it
Add pigs outputting the position change and all the factors that contributed to it.
Then you'll see exactly where it went wrong.
!collab
:loudspeaker: Collaborating and Job Posting
We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
β’ ** Collaboration & Jobs**
what are pigs
just put print statements
how would that work with the drag im a little confused
Autocomplete... It was supposed to be logs..
still having trouble figuring this out. commented out some stuff i had tried in the past that either errored out or just didnt give the results i wanted.
i also was suggested to use a script to dump component names using scriptable objects but binding.propertyName is just a string...
what are you trying to do?
im trying to get a list of all the possible values of binding.propertyName so that my script to copy those individual keyframes, also copies those /modifies them appropriately
probably more suited for #βοΈβeditor-extensions
can do
its this
Vector3 newPosition = Vector3.MoveTowards(
currentObject.transform.position,
targetPosition,
Time.deltaTime * speed
);
when I drag it on the y axis it bounces left and right and when I drag it on the x axis it bounces again
i tried smooth damp which fixed some things but made others worse
It's not "this". It's target position. Log it and every factor that is related to its calculation.
Plane plane = new Plane(Vector3.forward, currentObject.transform.position);
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
if (plane.Raycast(ray, out float distance)) {
Vector3 point = ray.GetPoint(distance);
targetPosition = point + offset;
}
this is the only things its connected to.
those aren't logs
okay
targetPosition = point + offset;
Debug.Log(targetPosition);
i did this and as I drag down the x goes back and forth
thats one thing, have you logged
currentObject.transform.position
targetPosition
newPosition
point
targetPosition
the idea here is seeing which part of the process is giving you trouble
Also actually add text to your logs to make sure you know what variable you're looking at.
i mean are you excluding the ball itself from all these raycasts?
i asked if thats what it was yesterday but someone told me no unless something is effecting the raycast
i thought that the ball might be messing with it
let me see
the raycast is smooth and fine but the sphere bounces and freaks out/bounces when I turn the speed up in
Time.deltaTime * speed
does ball have collider?
then its affecting the raycast
Also, moving physical objects should have rigidbodies.
Also, you shouldn't mix CharacterControllers with rigidbodies/colliders.
Oh, I guess you're not using CC...
i logged and put text, the x is changing on all of them
Debug.Log(("target position") + targetPosition);
Debug.Log(("point") + point);
Debug.Log(("current position") + currentObject.transform.position);
i did this
your right, now im trying to understand how i mean
I told you why.. it has a collider so it keeps hitting it and trying to move to itself?
use layermask
i do have a candrag tag on the obj(sphere) im dragging
would that work better than tags
imagine your shooting a gun at someone holding a shield
your tagging the shield
instead with layers you could outright ignore it's existence
only trying to drag it? you don't even need the raycast the whole time just when you need to pick up
i switched it to layer but still bounces.
I also use the raycast to check if crosshair is on sphere itself
this did help me understand layers better thank you
thank you for everyones help ima get some sleep and work on it again tmrw before I fry my brain lol
you probably want to keep the sphere at the same height, make sure you're not putting Z into account
Hello !
We are working at two on a project, and this windows recently hopened. I dont want to lose what i've done, my collegue just added one enemy on the scene or something, could someone help me what i need to do in order not to loose all i've done ? Thank you and have a great day !
I would backup the file of your scene first. than you can try to use that merge that Unity /plastic suggests. It might just be alright and add the object as well as your changes. Do you see any of your changes being written into the destination column?
But generally, just don't work on the same scene/asset at the same time.
You can workaround that with at least using some prefabs so one can work on their prefab while someone else can work on another without breaking the "Main" scene
You are trying to merge two branches that have modified the same file. To resolve the merge conflict decide on which lines to keep, by unchecking the other ones. Then save & exit and continue with your merge.
Hi! I'm having trouble with layers and raycasting
I have multiple objects I want to be able to click on (the brown cubes) and one object I want to ignore so that I can click on the squares behind it (the yellow rectancle)
I've tried setting the yellow rectangle layer to "Ignore Raycast" but that didn't work
I still can't click on the brown cubes behind it
The cubes all have this script that uses "OnMouseDown", but I've read online that it should still ignore objects with the "Ignore Raycast" Layer
If I'm correct (usually not), you've just set that box collider to forcibly include interactions with objects on the ignore raycast layer, regardless of the physics settings for the layer the gameobject itself is set to.
Instead look at the layer of the gameobject itself, above the transform component.
oh
you're right actually, that was the issue
thanks a lot!
@languid nova Besides the question but note that OnMouseDown only works for the old input system (which you then probably use), for maximum flexibility I prefer doing the same using a custom raycast. I don't know what you are doing but regardless all of those blocks having their own script sounds bit much especially if you are going to have a lot of them. Even them being separate game objects is a lot of objects to renderer. For more optimized approach, you could look into the way minecraft and similar games render blocks and modify them
I have scriptableObjects with ids. is there way to generate them unique?
look at Guid
Yeah I know that I am kinda brute forcing everything but this is just a quick prototype, not an actual game
is there function, which is called only on create?
On create of a scriptableobject?
You can use OnValidate and check if the ID field is empty
its executed whenever data is changed, but you just generate a new one if the field is empty
works thanks
couldn't you just use this https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Object.GetInstanceID.html
i think that's persistent for assets? not 100% sure though
Yeah that should also be usable, its persistent as its used to save references, but I wasnt sure if he wants multiple IDs like in a list or just one ID for the scriptable object so I suggested Guid
but you cant getInstanceId from scriptableObject
why not?
it worked, dumb mistake by me
Overy Object has that method
and basically everything in unity derives from that π
accidentaly didnt wrote "()"
I'd like to see the script before making any guesses. - Though that may not be relevant....... it's odd that it's only in the build
!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.
shouldn't have deltaTime on mouse delta, btw.
it's already per-frame
that's also a lot of wrong-lerp fyi
Applying lerp so that it produces smooth, imperfect movement towards a target value.
not seeing any issues that would affect jumping though
Mmm could be unrelated but i find it interesting that in the editor you were always moving laterally when you jump, but in build you're not.
Just checking in in case there is a more elegant solution
Is there a better way to determine if an enemy within melee attack distance height wise (3d) than to subtract half-heights from height difference?
like on pic magnitueds of a red vector minus blue ones
And then check if it's longer than allowed distance
Does this still occur if you're constantly moving forward/etc throughout the jump, in build?
send the script maybe
they did
i got the script from the asset store and then modified a bit, it just came that way
try to remove the gravity stuff
the char controller should already handle it by itself
it only does that if you move it using a method which does it
SimpleMove vs Move
iirc if you want it to jump you have to emulate gravity
you're supposed to, if you're using CC.Move
it's pretty unclear what logic you're describing here exactly
could you not just use physics queries or bounds intersection checks
Must depend what information you have easily available. In case you have the min and max coordinates, you could do a 1D intersection test https://eli.thegreenplace.net/2008/08/15/intersection-of-1d-segments. Maybe that way it would be easy to also set up a limited range of coordinates the weapon can reach height-wise, I assume in your case those boxes are the player and the enemy, you might want to limit the range to something much more specific for the weapon specifically and see if the weapon intersects with the enemy
Sure, might be an XY issue, physics queries are probably the more common way to do that whole intersection testing
what can I do with physics?
queries
I do that check to determine if an enemy should attack or not
o.O
could shoot a raycast and see how far it hits
or use https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Collider.ClosestPoint.html for a manual version i guess
from where and to where
results would differ depending on height differences
use OverlapBox or BoxCast
hey can anyone help me, im very new and am doing the 2d game kit tutorial, have done most of it with no issue but im stuck on the box problem ive done what it says and it just wont squash the enemy its supposed to
most of us have no idea what "the box problem" is so you're going to need to provide us details, code, etc.
keep going
This guide will walk you through setting up an empty Scene to start creating a new level with the Game Kit. This will walk you through some of the fundamentals used in this Kit to create gameplay. The Kit comes with a premade game, which contains examples of every part of the Kit in use if you get stuck for ideas.
If you're already familiar wi...
step 7
isn't it considerably more expensive?
no
ok but.. what part about it isn't working exactly? Show us what you tried and what's happening
it lands on the enemy and he takes it like a champ
2ns vs 1ns is a 100% difference but not meaningfully more expensive for most usecases
i even changed the dmg from 1 to t10
don't worry about perf at this stage. focus on what makes sense
nothing
Did you follow all the steps in the tutorial? Show us
