#💻┃code-beginner
1 messages · Page 774 of 1
another thing you could consider is whether stuff is diegetic - whether they exist in the world of the game
so....ui is basically above the game underneath O_O
well it does usually render last so thats somewhat true
like if in a multiplayer, the other person can look at their equipments and stuff, i won't be able to see that so that's ui
well, the inventory is UI. if you see stuff in the world on their player model, that isn't
so when dropping stuff, UI becomes not UI and a part of the game world...
here's another example. like before, the placement indicator could be considered UI, but it's handled closer to how the existing stuff is, so it's easier to not have it as UI in implementation
To make sure you understand, the item in the UI is merely a representation of the players inventory data. Once "dropped on to the floor" the UI updates and a prefab is spawned in scene to have the item on the floor.
so its not that we "moved it" but performed the correct actions to drop a thing on the floor
diegetic UI kind of blurs the line.
i remember seeing a game with a semi-diegetic inventory/hud that existed in world space, but that'd still be UI
halo has ammo counters on its weapons - that's certainly UI, but again, in world space
whoops, was meant to reply to this
so let's say, for what's gonna happen in my game...when i select one of the units in the unit selection area, and while draggin it, since it's not deployed yet, it's UI but then when its instantiated(when i drop it), it becomes spawned object. so when i might wanna drag a unit onto some other space, i will destroy the object, spawn it's image UI at my mouse pos, and then when i drop it, it becomes a gameobject again
also the selling stuff in lethal company or repo, with diegetic UI
ahh
while dragging it, i think it'd be easier to treat it as a world object, even if you'd consider that UI
i don't want it to be animating and hitting enemies while it's being carried...
but what you described is viable
you can disable those behaviors while being dragged, or use a different object (kind of like what you described)
which one would be better in your opinion
the former would probably be easier, less moving parts
so while dragging, it just stops everything and then when not dragging, it resumes whatever it was doing
could work
if you have a central component for managing the behavior, you could enable/disable that and then use OnEnable/OnDisable to manage the animation state, cooldowns, etc when picking up/placing down
but that's just one way to do it, just a matter of design
for future reference.
you will learn slowly, keep up the work. you already figured out the differences between ui elements and regular gameObjects

Hey I'm trying to make a tower attacking enemy but I keep getting this error
MissingReferenceException: The object of type 'UnityEngine.Transform' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Object+MarshalledUnityObject.TryThrowEditorNullExceptionObject (UnityEngine.Object unityObj, System.String parameterName)
UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj)
UnityEngine.Transform.get_position ()
Tower.Shoot () (at Assets/Scripts/TowerScript.cs:52)
Tower.Update () (at Assets/Scripts/TowerScript.cs:40)
(I tried to use the null code that I found online but doesn't seem to work)
anyone know where the problem is?
Line 52 is GameObject projGO = Instantiate(projectilePrefab, firePoint.position, firePoint.rotation); so firePoint has been destroyed
aah yes I see it now, thank you. Though something else came up instead but I think I got this 🙂
Is the setup similar to C# › IntelliSense: Add Type on Completion
try searching just the "add type..." part, then click the C# > Intellisense section
it has been banned, how can i replace it now
you don't need it anymore, as mentioned it's part of the unity extension
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
[Header("Parts")]
public CharacterController CharCont;
public Transform playerTransform;
public Transform camTransform;
[Header("Constants")]
public float movementSpeed = 100f;
public float jumpHeight = 250f;
public float offset_x = 10f;
public float offset_y = 5f;
public float offset_z = 3f;
public const float GRAVITY = -9.81f;
void Update()
{
print(CharCont.isGrounded);
var velocity = Vector3.zero;
velocity.z += movementSpeed * Time.deltaTime;
if (Input.GetKeyDown(KeyCode.Space) && CharCont.isGrounded)
{
var target_velocity = Mathf.Sqrt(2 * jumpHeight * GRAVITY);
velocity.y = target_velocity;
}
velocity.y += GRAVITY * Time.deltaTime;
CharCont.Move(velocity);
}
private void LateUpdate()
{
var playerPos = playerTransform.transform.position;
camTransform.position = new Vector3(playerPos.x + offset_x, playerPos.y += offset_y, playerPos.z += offset_z);
}
}
``` so the player jitters up and down and up and down everytime it touches the floor. how do i fix this?
nope. this is the only script in my game and it doesnt have arigid body
oh also your velocity seems to be wrong, you never compound gravity
what do you meann?
velocity needs to persist between frames in order to add continuous acceleration correctly, but you would also need to reset the downwards velocity while on the ground to not make your velocity go infinitely downwards
oh ok
your velocity is lost and recomputed every frame
you would need velocity to be a member field
velocity.y = -2f;
if (!CharCont.isGrounded) velocity.y += GRAVITY * Time.deltaTime;``` Changed it to this
that also doesn't make sense
how
consider what gravity is
it's an acceleration
if you fall for longer, you start falling faster
you don't compound gravity there, you basically set it to a fixed value that varies by fps a little
like an example?
do you understand what needs to happen though
yes
Vector3 velocity; // this being **outside** Update is important
void Update() {
velocity.y += gravity * Time.deltaTime;
}
```just something like this would achieve an acceleration
but the = -2f resets the acceleration
you could use that to reset down velocity, but you'd need to do that only if you're already on the ground
heres a video about whats going on
i literally could not tell you hwat happened to the quaility mustve been the monitor
getting a new one for chirstmas
i just quickly showed one sec
!ask
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #🌱┃start-here
what is the diff between 2d build in render pipeline and universal 2d
i wanna make a top down car game
"universal" refers to the universal render pipeline, URP
they differ in render pipeline
BiRP is the one that unity ships with, but unity also supports "scriptable render pipelines", basically custom RPs
URP is one of the custom ones
so i can create custom shaders?
you mostly don't really have to care, though some assets may support one but not the other
shaders will need to be for one of the other, or something like that.
this is most definitely not a code question though
you can do that regardless of RP
if you have further questions, ask #💻┃unity-talk or #1390346776804069396
ok
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
[Header("Parts")]
public CharacterController CharCont;
public Transform playerTransform;
public Transform camTransform;
[Header("Constants")]
public float movementSpeed = 100f;
public float jumpHeight = 250f;
public float offset_x = 10f;
public float offset_y = 5f;
public float offset_z = 3f;
public const float GRAVITY = -9.81f;
private Vector3 velocity;
void Update()
{
print(CharCont.isGrounded);
Vector3 move = new Vector3(0, 0, 1) * movementSpeed;
if (Input.GetKeyDown(KeyCode.Space) && CharCont.isGrounded)
{
var target_velocity = Mathf.Sqrt(2 * jumpHeight * Mathf.Abs(GRAVITY));
velocity.y = target_velocity;
}
velocity.y += GRAVITY * Time.deltaTime;
if (CharCont.isGrounded && velocity.y < 0)
velocity.y = -2f;
CharCont.Move((move + velocity) * Time.deltaTime);
}
private void LateUpdate()
{
var playerPos = playerTransform.transform.position;
camTransform.position = new Vector3(
playerPos.x + offset_x,
playerPos.y + offset_y,
playerPos.z + offset_z
);
}
}
``` ive fixed up the code a little trying to use what you explained
still jittery
(btw, you could just have the camera offset be a Vector3 and then add the 2 vectors)
yes, that's why i said btw
biggest problem first then the others
but it is still jittering
and i dont know why
is it jittering in the same way you recorded previously?
yes
could you show the inspector for the floor
Isn't it obvious? You're constantly applying downwards velocity to the object on every frame despite it being grounded, the object tries to move downwards, enters the floor, and gets yeeted up so as to not be inside the floor. Only apply downwards force when not grounded.
not how CC works, no. you need a constant down force to stay grounded
there isn't a depenetration force afaik, since it isn't physics per-se
usually i see something like 0.2, so maybe there's jank there with it being so large, but i don't think it's the issue
Yeah, unless there's a collider on both ground and player. Then good luck trying to make collisions not happen
physics collisions wouldn't happen if there isn't a rigidbody
the floor is literally a normal cube
does it have a rigidbody
please finish your thought before pressing send
it immediately jumps back to like persey 2 meters above the ground before going again and so on
but yeah im trying to find out how to fix it
idk, i guess try changing the grounded down velocity to something like 0.2f, that's what i usually see
also, the floor has a collider, right?
yessum
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
[Header("Parts")]
public CharacterController CharCont;
public Transform playerTransform;
public Transform camTransform;
[Header("Constants")]
public float movementSpeed = 100f;
public float jumpHeight = 250f;
public float offset_x = 10f;
public float offset_y = 5f;
public float offset_z = 3f;
public const float GRAVITY = -9.81f;
private Vector3 velocity;
void Update()
{
print(CharCont.isGrounded);
Vector3 move = new Vector3(0, 0, 1) * movementSpeed;
if (Input.GetKeyDown(KeyCode.Space) && CharCont.isGrounded)
{
velocity.y = jumpHeight;
}
if (!CharCont.isGrounded) velocity.y += GRAVITY * Time.deltaTime;
if (CharCont.isGrounded && velocity.y < 0) velocity.y = 0.2f;
CharCont.Move((move + velocity) * Time.deltaTime);
}
private void LateUpdate()
{
var playerPos = playerTransform.transform.position;
camTransform.position = new Vector3(
playerPos.x + offset_x,
playerPos.y + offset_y,
playerPos.z + offset_z
);
}
}
``` the code now. it still replaces my position at like a small amount
which means by my suspicion it would be this line thats causing the problem:
if (CharCont.isGrounded && velocity.y < 0) velocity.y = 0.2f;
instead it may be trying to reset my position to be 0.2 and once it goes to the ground then it replaces the thingy
why is it 0.2 ?
idk man
almost as if what I said previously, was right, go figure
thanks for the overwhelming help guys :]
ah shit right it should be -0.2f (or -2f would probably also work)
not for getting proper ground checks
like think about it, if your character controller object, which by definition is constrained by collisions, enters another collider, regardless of having a rigidbody or not, it needs to exist outside the space of other colliders. so it will jitter towards the closed exit point, if it enters another collider, which so happens to be above the floor.
Then, you're constantly adding delta time to velocity for no reason, which gets applied as soon as the character controller is yeeted up outside the floor collider, which goes down, rinse and repeat.
nope, this is wrong
0.2f makes it go away from the floor
how so ? thats how unity does it, worked fine for me 🤷♂️
hasn't this been discussed a ton of times
it should be zero, there's no reason to move downwards a character that's grounded
isGrounded checks if it hit the ground the last move
there's been a ton of discussions here that have been resolved quite easily by just adding a grounded downvelocity
isGrounded is too finnicky , I'll stick to overlap / cast
Was the CharacterController touching the ground during the last move?
https://docs.unity3d.com/6000.2/Documentation/ScriptReference/CharacterController-isGrounded.html
yeah, in specific situations in which people where not doing things properly, then, you need shoddy attempts to make things behave
@rich adder haven't i had this exact convo with you before, actually lmao
the proper thing (in terms of using CharacterController.isGrounded) is adding a small grounded down velocity
idk my memory is shot lmao..maybe too much 🍃
i definitely had this convo before.. im not super confident it was with you though
I think the old example code in CC.Move did have -0.2f so I don't disagree, I just hate using IsGrounded personally and always recommend the spherecasts/overlap
ykw im not gonna use the built in charactercontroller.blahblah thingy isCheckedGround ima use my own
why would you need to apply downwards force, to a character, that's grounded? Like, literally where he should be, if no other thing changes him upwards? Why do you need him to be slightly underground?
spherecasts especially if you need slope detections / normal
if you don't then you're basically floating on the floor, no?
What do you think isGrounded means?
if it hit the ground during the last move, in the context of CC
if you didn't move towards the ground, you don't hit it
I think it had to also do that velocity is not exactly 0 like if you inspect a rigidbody falling on a floor its never exactly 0 and fluctuates "grounded"
- just kinda "sticks" it to the floor
yeah, but you're checking it before applying move, the character would have moved on the previous frame, if he was grounded previously, why do you need to move him down?
so he stays grounded
a new move is made. if you don't hit the ground then it won't be grounded the next frame
Which is what the isGrounded check is for, if he's grounded, he does not need to be further grounded, that's crazy
Specific question about VContainer but maybe somebody can help me here as they dont really have a support discord or anything like that
Is it possible to have a "sub installer"? So i can split my LifetimeScope up into features and not have every single class in the main file?
frame 1: not grounded, moved into the ground (hit, isGrounded = true)
frame 2: grounded, no vertical move (no ground hit, isGrounded = false)
frame 3: not grounded, moved into the ground (hit, isGrounded = true)
frame 4: grounded, no vertical move (no ground hit, isGrounded = false)
ahh never mind, it was with praetor
It's literally right here: https://docs.unity3d.com/6000.2/Documentation/ScriptReference/CharacterController.Move.html
if grounded, no velocity, downwards force is zero...
ya was gonna say, I don't know much about it to comment on it.. I just know the one time i used IsGrounded in the beginning it was too simplistic for me so I stuck with Physics Queries
unless, you did weird things somewhere else, then you need to course correct, because you programmed it wrong
but its true, even unity has -0.2f in the old example, not sure why it changed .. i think..
im sure if waybackmachine it , you will see
do you mean the docs or the example
the example is an example of how to use the apis, it's not necessarily the correct or good way in the context of a system
mb
at the end of the day this is just a C++ controller in PhysX unity is just creating an api for you
I'm not going to try and keep explaining how to do things properly, to someone that believes vehemently, that things should be done the wrong way.
how do i like, not get scared of using unity
I'm curious, has anyone dabbled with actual StateMachine implementations for Animations, where you'd do something like manage the states and just use something like StateIds, then in the Animator you'd just do Any State -> States (Cannot transition to self). I started doing states in the Animator but honestly I had 50 arrows going everywhere, how do you manage this if you do it some other way?
i copied the example script into a test scene. isGrounded fluctuated between true and false while stationary on the ground. what a surprise, the description of the docs is more accurate than the example
um this is a coding channel
gain experience and thats how you do it
is there a coding question here ?
if I create bad code, then use a "fix" to make my bad code behave as if it wasn't bad in the first place, and then believe I fixed the issue, I'm just a person who creates bad non functioning code all the time. I'd rather be the person who learns how to do things properly
i changed the grounded downvelocity to -2 and it stopped fluctuating
i changed the grounded downvelocity to -0.2 and limited the framerate, it stopped fluctuating
this is literally how isGrounded is documented. it's what isGrounded expects
what even is the "bad code" here?
unity's example?
this just feels like willful ignorance at this point
Just one thing about this, in a perfect world we would all create perfect code, but in this world that will get us nowhere, you can now write things you deem perfect and in half a year you will come back and think "who wrote this garbage", trying to iterate over and over to create the "perfect" code will do one thing: stall your progress
I've been there, not wanting to end up with "garbage" code when the project progresses but you have to find a middleground and accept that you can always refactor in the future
Perfect, and properly used, are two separate things. I can just rotate the camera 180 degrees, then code the whole game using inverse numbers everywhere on vectors, have to change everything 3rd party that I add to it to comply with the fact that I'm for some reason doing things like that because I believe that it's how it works, code runs all fine but I keep having to compensate on things everywhere. would you call that good code? It works doesn't it, that should be enough right?
if you have a 3rd party library that does things that way, then sure, doing that would be correct
that's the case with CC
the isGrounded check expects you to hit the ground
that's what the downvelocity is for - supplying that expectation
You're sure a persistent person, I can give you that
did you like, read the docs at all
im going through the message history regarding isGrounded and it's basically either 2 things
- don't use it, it's easily misunderstood (you need a down velocity)
- apply a down velocity and it works fine
you're stuck in an assumption that the unity example code is perfect, i guess? or that isGrounded must conform to your expectations of it?
Hello fellas! I am recently self-teaching Unity's latest behavior system via behavior graphs. And I have been struggling to create my own customized flow node to randomly select the next branch to execute with weighted probability.
So basically, I want the customized flow node to read a blackboard variable whenever the node executes (OnStart()) that is controlled and manipulated dynamically outside of the graph. What I did is this:
[SerializeReference]
public BlackboardVariable<float> ChanceVariable;
What I expect to see is when I open up the node's inspector panel, I would see an empty bbv called "ChanceVariable", waiting for me to drag a bbv into its empty slot to establish a direct reference.
However what I see is nothing. Like so...
A thousand thanks in advance!
but i guess that's exactly the issue of isGrounded, it's commonly misunderstood, like in this case - you need a constant downwards motion to have it work properly.
if you think about it, normal unity physics and real life also have this.
i guess it's an issue with CC as a whole, it makes some assumptions that might not be in mind (Move/SimpleMove expecting to be called once per frame is another one, for example)
isGrounded, as per the docs, checks if the character was considered grounded as per the last call of Move on the character controller.
If you use the character controller, you should exclusively move the object using the character controller, and nothing else, no rigid bodies, no transform.position.
If, you're responsible of when and where you moved the character, using it's controller, and the character is not where it should be, and you need to compensate for it's position, you moved the character in a wrong manner, simple as that.
There's no ifs and buts to this, you caused the issue you're trying to correct. Aka, bad code.
checks if the character was considered grounded as per the last call of Move on the character controller.
no, it checks if the last Move made it grounded - if the last Move hit the ground.
if the last Move doesn't have any motion towards the ground, then it doesn't hit the ground
Exactly, guess what code called move last time?
you're only thinking about 2 frames
i literally gave a frame-by-frame example earlier
the previous frame, gravity was applied. now you're on the ground
the current frame, you don't apply gravity because you're on the ground
the next frame, you're no longer "on the ground" because you didn't apply gravity last time
I'm not thinking about frames at all, this has nothing to do with frames, I can call move twice, check grounded, call move again, and check grounded again, on a single frame, and it would still work.
isGrounded doesn't check the previous frame, it checks what happened after the previous call to Move, which is what you're not understanding.
Move is called once per frame
that is the expectation of CC
you can call it the previous cycle or previous update or whatever
my argument doesn't change
the previous call to Move was the one with gravity, and now you don't have gravity. what happens the next cycle?
even in the example code, Move is called once per frame
this is an issue with documentation.
It is recommended that you make only one call to Move or SimpleMove per frame.
this is documented in SimpleMove, but not in Move for some reason
https://docs.unity3d.com/6000.2/Documentation/ScriptReference/CharacterController.SimpleMove.html
oh dang, they finally updated the .Move docs to actually only call Move once per frame. it's been wrong for years
so, do consider the "over time" element of this. the code that called move last time was the Update of the previous frame.
the code that will call move next time will be the Update of the next frame. that's where your model will break
one thing fixed, another thing broken 😔
the grounded downvelocity was removed
good luck with your endeavors.
one, can't be a person that says "look at the documentation" and also be "The documentation is wrong" at the same time.
the documentation is lacking, not wrong
the examples are wrong. examples are commonly wrong.
wht downvelocity are you referring to?
also, despite the change to only calling Move once per frame, the docs are still using a Vector3 for playerVelocity which is only used for its Y axis to apply gravity/jump. it's silly because that could just be a float, they aren't even using any other axis anywhere
Could someone help me with optimizing? I have reduced using physics as much as I could but it still lags very badly, I get that the issue is like right in front of me but I still don't know what I should be looking at.
was referring to the one in the if (playerGrounded && playerVelocity.y < 0) check, but seems like that's always been 0.
the grounded downforce is supplied by unconditional gravity.
i probably misremembered from someone asking about tutorial code that went like this
if (isGrounded) {
velocity.y = -0.2f;
} else {
velocity.y += gravity * deltaTime;
}
would you look at that...
the grounded downforce is supplied by unconditional gravity.
not sure it's enough though. it still fluctuated a lot, but at least not true -> false -> true -> false like it theoretically wouldve been with no grounded force
so this kind of code would probably still be better
you do realize that everything they said is still accurate and that you should be applying gravity to your single Move call each frame, right?
hm, though, yeah, this is framerate dependant.
in a barebones scene, -2f didn't fluctuate, -0.2f did fluctuate until framerate was limited.
so maybe something like velocity.y = gravity * deltaTime * 100; or some factor would be better to keep things grounded
look at.. what? the gravity that isn't enough to keep things grounded?
seems like whatever work you are doing inside of FixedUpdate is the biggest issue and not necessarily using physics
Ok il take a better look there
I was looking at the wrong thing then
Messing and improving the physics did nothing so that explains it
wait the factor here combined with movespeed indirectly controls how steep a slope you can walk down while still being grounded lmao
this is why i use the KinematicCharacterController and not unity's built in CC lmao
how does it handle gravity/how does it handle gravity differently?
oh wait, it's just a physics simulation lmao
it's almost as if, raycasting below the character, isn't the proper way to check if a character is grounded or not... Instead of thinking that just because a variable name somewhere else implies something, it means it should be used always for that.
Go figure...
isGrounded isn't a raycast
which is exactly why it shouldn't be used at all times to see if the character is grounded... Like I said...
I'm responsible for what I say, not what you understand
the phrase "it's almost as if X" means the speaker believes X
you just complained about how raycasting shouldn't be used for ground checks, then Chris pointed out that isGrounded is not a raycast (because it isn't), then you just said that's the reason isGrounded shouldn't be used (or at least implied it with how you worded your response)
but sure, i concede that this isn't a particularly good way to go about ground checks.
but that's just not what the convo was about at all lmao
which is why the value is always intermittent, which means that if you apply "fixes", so that it behaves the way you want to and not what it was meant to be used for, is bad code, which was my point from the start.
the fixes are for your own code for violating the assumptions set by CC
it has nothing to do with CC being designed weirdly
if you want to complain about fixing bad code, you would be complaining about CC, not the code using CC
Which is exactly what I said previously, that you're fully in control of what the character controller does, hence if it behaves erratically, it's you who did that.
If you want i can have a quick check, also good to know would be how many enemies you have on screen
The callstack right now suggests 1000 calls to player fixedupdate and 16000 to enemies, you cant possibly have that many active?
or looking at it longer it looks like fixedupdate ran 1000 times in that one frame
Nope, the CharacterController is working fine, if you use it correctly
yeah.. if you violate the assumptions, it's your bad code.
not applying proper grounded gravity violates the assumption.
not applying proper grounded gravity is bad code.
do i really have to spell it out for you
Yeah I have 6, it lags a little and when there is more then 10 it drops to like 5fps
Believing that isGrounded, should always be true even when you don't move the character downwards previously, is misunderstanding what isGrounded is for
It didnt lag like this but I changed some stuff and I dont remember what and now it dies after 6 enemies
yes.. and that's what your understanding was
#💻┃code-beginner message
did you like, figure out my explanation and then you're trying to argue that back at me?
what is going on here 😂
I'm not the one who believes that, I need to always apply downwards pressure, so that a variable that shouldn't always return true, now start returning true, you're
#💻┃code-beginner message this too
"no reason" other than fulfilling the assumptions set by CC, sure...
Your assumption, because you believe that is grounded should always be true, as a ground check, and not as "last move it touched the ground" which is what the documentations says it does.
isgrounded should always be true if you're on the ground, what are you talking about
so your Moves should make it so that assumption is fulfilled
are you ok
you might need to step back for a bit
well, you clearly understand what the grounded downforce is for now, so i guess my job here is done. i have no idea what's going on here after this message lmao
JESUS, no, it should be true if on the last move, the collider for the character controller, entered another collider on the bottom. It then places the collider above the collider it touched, now you just move forward as long as you don't apply downwards force to it, no need to check it again.
"am i grounded" should only be true if you just hit the ground?
ok, how do you detect if you leave the ground, or if you're currently on the ground
the docs just say how isGrounded is computed, nothing about that says it should only be true when you initially touch the ground
this is some insane reaching
Raycasts, like a sane developer
then you wouldn't be using isGrounded to begin with
i'm asking in the context of CC itself
what im seeing here is that isGrounded and Move don't fit the assumptions you have, and now you're just reaching for arguments to.. i don't even know what, at this point.
this is just trolling at this point lmao
Going as far back as I could, its so entirely unclear what this person is trying to get at here lol
The commas make this very unreadable too
tbh i still dont know what the conversation is about
because you're interpreting the explanation wrong, it says it's true if last move touched ground, but if it did, it will place the character controller above it, because it's constrained by collisions. Then, if you never move the character down anymore, you don't need to check if he touched the ground, it's simple as that. Because the character would never move down anymore, since you're using a character controller. Then you should apply gravity to it, if the raycast for isgrounded fails. And then, you could check for is grounded again.
if you use CC correctly, isGrounded acts basically the same as a raycast, just less configurable
if you're using a raycast, you wouldn't be using isGrounded
that's just using 2 tools for the same task, but using one of them poorly
let me ask you something:
if you stop applying gravity once the CC's isGrounded property is true one time then you stop moving it downward ever so that its isGrounded property is no longer true, then how would you determine that it is grounded to do something like perform a jump? You've stopped applying downward forces to the CC so it's no longer considered grounded from its own ground check
footnote: without raycasts. that defeats the purpose of the question
damm this is still goin on ..😆
Not true at all. Because the is grounded only return true with the last move, and that's where the bad code is, you don't need to move it down all the time, if the raycast still detects him on the ground. But, when you're moving the character down with the character controller, you might need the point of view of the character controller if it touched down or not, to stop applying downward forces, because the raycast is not aware of the the internals of the character controller, isGrounded is.
dude cannot comprehend that you can get a boolean that's like what the raycast does but without the raycast
CC.isGrounded IS NOT a raycast. and WILL NOT detect ground if the CC is not being moved downward into the ground each Move call
hey i did the ground checker in unity fo double jump and now its is infinite can smbd help me
because the raycast is not aware of the the internals of the character controller, isGrounded is.
raycast can be aware. the internals are exposed
so.. you just.. don't know what's going on here at all, do you
sheesh, like I said, you check to jump with the raycast, not with the isGrounded from CC.
show code
you most likely did it wrong or including the player and grounded on itself
isGrounded <=> raycast
A tool for sharing your source code with the world!
not at all the same thing
heres my code
why do you keep flip-flopping on this. at one point you said you shouldn't be using a raycast for a ground check, now you are saying you should rely on both for some reason? you just need one or the other. and isGrounded works perfectly fine provided you are correctly applying gravity every single Move call even when it is grounded already because that's how gravity works IRL too
not saying they are. but, if you use both correctly, they do the same thing.
if you're saying isGrounded should only be true only for the moment you start touching the ground, you are just plain wrong. no way about it
IsGrounded works fine if you follow the rules of character controller and call move exactly one time per frame and always apply gravity.
If you're using a raycast that's fine but it questions why you would be using isGrounded at all, which calls into question why you're not just using a Rigidbody if you're going to manually be doing most of the things CharacterController gives you for free.
you gotta give me time to parse this poorly formatted code, mate
ok cool im new so ye based
plus i have another for player
you should consider using the formatting tools in your IDE to format this so your spacing isn't all over the god damn place, it's nearly impossible to read because of that
I believe what he's saying is that isGrounded is true only for the one frame. Because CC is supposed to keep having downward force applied to it. The CC only sets isGrounded if the last call to Move collided with something from above. It's a common mistake to set the y speed to 0 when grounded, causing the object to rapidly oscillate between grounded and not.
oh alr
how to do that
idk, i feel like we've been over that several times. i gave frame-by-frame examples and empirical evidence about that.
where are you calling tryjump?
you never use it in this script
depends on the IDE, in Visual Studio it should be ctrl+k,ctrl+d
Hi, how can I the small zone where uses "Navmesh Surface", but that zone it's part of main world
i cant not see anywhere in your code a jumping command nor where you call the tryjump method
This is what is grounded says on the docs:
Indicates whether the CharacterController was touching the ground during the most recent call to CharacterController.Move or CharacterController.SimpleMove.
This property is updated after each call to Move, based on collision detection with the ground. It returns true if the controller collided with any object below it during the movement — typically used to determine if the character is standing on a surface (e.g., terrain, platform, floor).```
Now, colliders detect collision, when one overlaps the other. If the character controller positions the collider of the object it's attached to, just outside enough of any collider it touches, so as to not keep colliding anymore, should it still collide with the ground, if you don't move it downwards?
Ive set the VSCode shortcut to be the same as Visual Studio, but you can also right click it and "Format document"
if using vscode *
I think the disconnect is just in how to fix it, the proper way is to keep applying a small amount of downward force even when grounded, while they are saying to use a raycast to circumvent the CC isGrounded at all.
Both are valid solutions, although the raycast method means you're no longer using all of the CC's utility and should consider whether you actually need one
should it still collide with the ground, if you don't move it downwards?
no
that is the entire point we've been discussing
you should move it downwards, so it collides, and you get a useful boolean
its in my second script i can send u guys it
It wouldn't, which is why you want to give it a smidge of downward force even when grounded.
only the code of interest please Jager
yeah, share it in the same way you did for the first one. (also you can share multiple files together with pastemodgg)
but yeah ideally it'd just be the relevant bits
not entirely true if using raycast overlap tbh.. slopes alone is worth using CC, cause rigidbody is garbage for steps as well.
raycast / sphercast is just better results overall and you get normal for other slope calculations
here is my second one
A tool for sharing your source code with the world!
for the movement use
Ah, right, slopes. Forgot about those. Yeah, might still be worth using a CC with some physics then.
Why if you're already on the ground? You need to move downwards when you're not on the ground anymore. Which is why you have a raycast, which constantly checks if you left the place that would keep you grounded, instead of constantly making unecessary calls to Move, even when standing still.
isGrounded fulfills the role of the raycast
Gravity always exists
does gravity in real life just stop working once you're touching the ground?
regardless you still need Move every frame, wdym unnecessary
instead of constantly making unecessary calls to Move, even when standing still.
you're supposed to call Move every frame, there is no loss here
You're always moving towards the ground even when you're standing on something
contrarians man..
not with a character controller, if you need constant gravity, you use a rigid body. That's the whole purpose of character controller, to only apply gravity when it's needed, according to your needs, and not just full time calling Move just because you don't understand the documentation
Of course there is, are you telling me your character should keep moving when he's standing still?
yes. gravity exists
i dont understand anything
That's the whole purpose of character controller,
where is it written that CC has specific purpose for what you say
@thorn crescent consider a platform moving downwards.
you're the one not understanding the documentation here, mate. even the docs show that gravity is being applied every single frame, even when grounded
Steps would be more of a design issue, where you could either fake it with just a slope and still use rb or acknowledge the object will need this functionality and use the premade cc functionality.
Slopes isn't really an issue if you handle gravity yourself
i don't even know what to say to lead you here. it seems pretty obvious to me
you should be grounded the whole time
No, I understand the documentation. I've explained this exact situation to hundreds of people on this server. You need to be calling Move exactly once a frame, every frame, and you need to have gravity even when grounded, just like how gravity always works.
you shouldn't be falling then on the platform then falling again
Jager your code is really messy. where do you determine the landing and isGrounded bool
really all that CC gives you is crappy capsule collision detection and the ability to walk up stairs
if you handle gravity yourself you're back to doing the same thing, using RB as kinematic controller.. which is essentially what CC is
starts from physics parameters
Not at all, you can simply disable the gravity on the rb. Doesn't have to be kinematic at all
rb kinematic is superior in many ways
Yes. Because you need to call Move every frame.
@glad dagger it seems the verticalvelocity > 0.01f may be the cause.
keep in mind that && is applied before ||
so if you can double jump, and you've jumped twice already, but your vertical velocity is <= 0.01 (falling), you don't return
Is all your floors constantly falling for you to apply a downwards force at all times? Is that really your argument? You should always apply a downwards force, because sometimes you might be on a moving platform, instead of checking if you're on one? Do you understand now what I meant by bad code?
what do i do
so would you rather have uniform code applying gravity as it should, or a special case just for a platform that moves down
No, the argument is "you should always apply a downward force because that's how physics works so that's what the system is designed to do"
I don't know how to be clearer that a character should only move, when he moves.
so then what is the benefit of RB over a CC ? the only thing I don't use / like with CC is the built in IsGrounded, everything else I prefer it so not sure what you're saying.. Now you have other physics objects that will affect your motion without gravity on non-kinematic
Which if you care about physics, you don't use a character controller...
I don't know how to be clearer that a CharacterController should only have Move called, every single frame
I don't know how to be clearer that you are wrong, Move must be called every frame and that gravity always exists.
You don't need to, because that would be a wrong assumption
do you also not care what the system is designed to do
yeah, ok
you have no idea what you're talking about
It's not. You are the wrong one here. The system requires you use Move every frame to keep in contact with the ground. It doesn't matter how much you think it shouldn't, that's how it works. Write your own character controller if you don't like it.
Its all just up to the design of the game. Like if the player is a rolling marble its definitely easier to setup with a rb.
A person that's wrong on how to use something, is telling a person that uses it right, that he's wrong, is that it?
you see 6 people telling you that your assumption is wrong and you conclude that every single one of us is wrong
that's wonderful
Its clear this is going nowhere. The one who should be learning thinks they're the one teaching
well sure sure, was just saying.. In most cases I like the Out The Box slope / stairs / elevated steps out the box with CC.
cc slope doesnt even work correctly
You aren't right though. The documentation says it, everyone here is saying it, the code says it. Just put some fucking gravity on your CC and call it a day
who uses a cc anyways
in what way ?
Run off a ramp with forward velocity and you will tumble down it
idk man i live in 2d. but somehow i can read documentation and previous convos enough to understand systems
due to custom gravity, you can easily fix that tho by moving on sloped normal dir when going down
No, it doesn't after you touched the ground, you're grounded, because the character controller would never move you on it's own, only when you call it to. If you believe that you need to improperly move the character downwards, instead of only doing so when a raycast tells you that you left the ground, you clearly don't understand how the character controller works, and just because you've been using it wrong all this time, but "it works", doesn't mean that's how it should be used.
Yeah, but then you're modifying it at that point, no?
what are you trying to achieve with that velocity check?
You can similarly just do RB with that logic
yeah just project the velocity and "it sticks" its and easy fix
The steps also can be faked by just having a slope as a collider while the mesh is stairs
In some cases
Buddy.
Mate.
Friendo.
Gravity does not stop existing when you are standing on something.
it does with the character controller, if it was supposed to have gravity by default, you would use a rigidbody
i just wanted to check if the vellocity can be changed
I'm talking about gravity as a concept
I found that most cases the Rigidbody slows down on slopes or gives unwanted results, especially if you want actual foot IK to look right on stairs.. as you said now this is very specific to the project so kinda moot
The idea of gravity
You can fail to implement gravity
But if you want gravity
You have to add it even when you're on something
just because, you have the belief that, for some reason, gravity must exist at all times with a character controller, but somehow just at a .2f instead of it's full value, then you like to do things in the wrong way
this is like a troll post at this point yes?
thankfully, that concept is an alien thing to the character controller, unless the person who codes it, wants it to exist, then he can do it as wrong as he wants to
it can always be changed, not sure what you mean by that
It's not a belief and it's not the wrong way. It's literally what the system is designed to do. Please disengage your head from your colon and realize that you misunderstood something in the documentation.
Yeah at this point I think we need <@&502884371011731486> intervention
Slowing down would be more if you arent projecting the movement along with the slope. It'd be a similar issue with cc although might look different because the rbs velocity would still change in relation to the normal
I can eat soup with a fork my whole life, and arguee that that's what forks are made for, you just have to slurp the juices at the end for it to work. Doesn't mean I would be right just because I believe I am
true but when u jump u can check how it like from -3 to smthng else
And I can make false equivalences where I'm right and youre wrong. Doesn't actually prove your point.
Yes which is why my first post in this whole debacle was defending your choice to do it wrong and suggesting that maybe you go one more step and just use a Rigidbody.
But it is misusing the CC. You can do so for a purpose, but it isnt the "correct" way to do it.
what are you trying to achieve?
The irony here is palpable. You're yelling at people handing you spoons and shouting that your fork is the right way
yeah not sure where I disagreed tho, I just prefer a kinematic controller usually than something affected by outside forces. Mainly my thing was using the IsGrounded is too basic but should be ok for some cases. I got used to LayerMasks and casts to have more control
is it very shit
this is sounding like an https://xyproblem.info
what does that condition achieve for you?
show me a method on the CC, that constantly applies downwards force, by just calling it without passing a downwards force to it, and I will agree with you that that's how the CC is meant to be used.
oh, like SimpleMove?
is true simplemove applies gravity
Ok, do you need to pass the direction of where it should go or no?
soooo are we going to see more strawman arguments
yes, but it's projected onto the xz plane. y is ignored
it's also in speed rather than delta position
I don't get why you are still engaging with them at this point, this whole discussion makes the channel toxic for everyone who might already be insecure about asking questions
ngl idk im new i just checked some youtube videos and slapped it all into one script
have you tried just removing that bit of the condition then
ok, then that means that the method only goes where you want to, can you call it without passing a direction? Does it move down at that point?
in general you should probably check if you can do something, rather than checking if you can't
being a contrarian just to stir a reaction
CC applies some cals when sliding such as going up ramps, but you don't necessarily need the downward force, but that would be included in the consideration.
you don't pass it directions.
Literally nothing happens in code unless you write it. This is asinine.
no i havent
try it
also for stuff like this, you should generally check if you can do it, rather than if you can't
And yes, if you give it 0,0,0 it moves down
I was more commenting on the slowing down aspect because thats more of a developer mistake rather than an issue with a rb. I dont particularly have an opinion on anything cc related
something like this would be more straightforward
if (isGrounded || (canDoubleJump && jumps < 2)) {
// jump
}
``` @glad dagger
how so? Where is the gravity set on the character controller, for it to know how much to move down?
It's set in the physics settings of the project
It uses the Rigidbody gravity value
Which applies only to rigidbodies and not the character controller, since it's not controlled by physics...
Which means you misunderstand how the character controller works
Except it literally does apply to the character controller that's what I just fucking said
anything can use Physics.gravity. what are you talking about
https://docs.unity3d.com/6000.2/Documentation/ScriptReference/Physics-gravity.html
If it had constant downwards force, why would you need to apply it to?
Anyway, let's end this discussion and just forget about CC because it's obsolete when you can just go onto the asset store and download the Kinematic Character Controller for free
because people aren't using SimpleMove
Move gives more control
Because if you specifically choose not to do the one that automatically applies gravity, you have to do gravity yourself.
if you teel it to, it will. Do you need to call a method for the rigidbody to fall, on all frames?
yeah but originally I mentioned the out-the-box going up slopes was a big reason i already preferred CC over RB replying to what digi said
Buddy put down the goalposts we already scored a point you don't have to move them any more
By your own stupid fucking requirements we found the method. You lost
are you, yourself, adding code to the object, to make it fall? Don't start using semantics
should i delete time jumped
buddy, you believe physics on the project, affects the character controller by default...
no, that's what jumps is in my example.
if you use SimpleMove, yes
you can easily test this
hey dude u got any videos to make better cause i think ima remake this
If you don't code in something it doesn't happen. Things don't just do things in a program of their own volition. This is a goddamn farce and you're a belligerent prick who will never admit they're wrong when proved a dozen times over.
You really need to take time and reread what youre replying to. Its clear you arent understanding whats being said
Anyways what happened to this
#💻┃code-beginner message
Where's the agreement after seeing simple move?
It's probably hard to follow the answers when theres some wanker arguing against the universe constantly
Especially considering the adjacency of the subjects
I dont even think they're trolling. I really think its just a reading comprehension issue
So let's all just let igneom scream it out in the void and focus on the actual problem
it's so obvious too. you can change gravity at runtime
It's ego. They know they're wrong but won't admit it
There are going to be tutorials you can find online. Most tutorials arent good for a final product. Look for them and use it to learn.
Really learning to debug or understanding what your code is doing line by line will help you solve this
oh dude i how im bad at learning
there's no time limit, you can take your time
but ultimately, it is a skill you need to practice
i don't know which channel ist the correct one. but does someone has any idea why my material is shown black?? it's an imported asset and the developer donesn't know either.
ye but is there any more tips
definitely not a code issue
(make sure the asset supports your render pipeline)
In a sense you do expect CC to have a lot of it fleshed out already, but it provides very little to rb that you couldn't write in few minutes top
can someone help me modify a gorilla tag map? i need help changing a few textures and moving/removing objects
we don't support modding here, sorry.
CC should have params for slopes, stairs, moving platforms, force relativity
instead you get some half-baked controller
yeah i know but where can i ask this? 🫠
i gave you 2 channels
(though, choose one to post it in, don't crosspost)
I think CC is the best for prototyping. Nothing is perfect. U get a lot of options to create a controller on ur own. It’s only the matter of skill
oh sorry i didn't know this option - not on discord often xP
oh shoot i put it in the scripting channel
modding isn't supported in this server as a whole
wdym modding
you're modifying assets from an existing game that you don't own, right?
not the actual game
i'm taking a download of the map from online and changing it for a scripted video
oh, "gorilla tag map" meant a map for gorilla tag?
ye its a download of the gorilla tag map so i can make it look corrupted not the actual game
are you modifying it in unity?
if you're using an external tool like blender or something, it'd fit better a server for that
also, please don't crosspost.
also,
!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 is crossposting
posting the same issue across multiple channels
why when i said "bruh" it got blocked
there is a message that says why
ik but why
Because you are spamming the channel with useless messages.
anyways @manic stratus see above, in case you're trying to look for people to work on the project with you
it's not a project i was js asking how to change a texture
you can ask about that stuff upfront, and ask in a single, relevant channel
that's also.. quite a generic question, perhaps google that
Normally you'd provide what you've tried and folks would add in on what you're perhaps mistaken on
i have no experience with unity
Else the way you've got it above feels more like a collaboration request
You'll still need to provide information on what you've got in front of you in fine detail and folks would hopefully direct you to some proper tutorial on how to accomplish your task. Else it's more of a service request (collaboration etc)
in front of me i have my monitor and i just downloaded a copy of the gorilla tag map
i want to edit the texture of the branches to make them look corrupted
this is a code channel so unrelated..
also no modding help
So like for instance you'd provide folks with info about the file type, what needs to be changed etc so that they can further assist you. Wrong channel, yes.
yeah mb, i extended the convo about allowed content since they crossposted to 2 other channels and i was indecisive on which to continue in lmao
gtag /roblox has top tier slop
what do you guys mean by modding
i'm not changing the actual game
its something like this
Disturbing Footage of a channel called @ChimpGT-d2j who gets on Gorilla Tag to play with his friends, little does he know this version of the game might not be what it seems.
Discord: https://discord.gg/PHUuzCcpHH
Thumbnail Discord: https://discord.gg/XcuhB8nmH8
Thank you for watching: Found Footage Of A Corrupted Gorilla Tag Ghost
at the 2 minute mark you can see what i'm trying to do
I'm not watching watever slop that is. Also again wrong channel and is it even unity related 🤔
he used unity to change the textures
to mod.. which again is against server rules
this isn't doing anything to the actual game
you know that right
you do know that modding literally means "modifying" and by a synonym for "modifying" a texture is "changing" a texture. this is literally modding. ask in the game's modding community
how is changing a texture not allowed in the server
can you not do that in unity
this server is not to help you mod a game you are interested in. you can ask for help with that in the game's modding community. this server is to help develop your own games. the way these things work is wildly different
Is there a way to get the one shot audio gameobject so that it can be configured in the code?
i can imagine you would have to add a check to see if it still exists as well
use your own AudioSource object instead
Yeah, i've been feeling awkward about audioSources. I don't really want distance based sound for the most part.
Create an instance and you'll be able to continually configure it
in my current project atleast
they don't have to be
True, that's a much better approach
(that's the same as my suggestion)
Is there a setting for that?
https://docs.unity3d.com/6000.2/Documentation/Manual/AudioSource-reference.html the spatial blend part can be set to 2d
Thanks, i'll read that right away.
if u walls cut out the navmesh it should walk around them..
isn't navmesh for 3d
ohhh im blind
please don't crosspost
is there some terminology to help me find some resources on headbob - weaponbob
ive done 1 dimension but not 2..
and i believe u can do the same sinewave type thing for both vert and lat movement.
i worked on it a bit yesterday but no good results.. ive found something about using the same code but having it be out of phase.. but the out of phase part is what i can't get working.. the tests i've tried always result in a perfectly straight diagonal movement
not out of phase -- with different frequencies!
e.g.
Anyone able to help in https://discord.com/channels/489222168727519232/1442198340551970816 im out of ideas
why is unity easier then unreal
this is NOT a coding question..
sry i thought it was
oh that makes more sense.. let me try to adapt my code real quick.. i shall return if i have issues || i'll probably be back, lol||
maybe people compared c++ with c# and came to the conclusion that unity might be easier. however you got blueprint (visual scripting) in unreal which makes things a little bit easier than using c++
i was never good at sin + cos stuff.. you're a saint 🧡 exactly what i needed
yalll ive some questions. im making a unity 3d story based game and have my models animations ready but how to i incorperate the story tho like ik the script (story line) but how should i code it
By following tutorials and getting back to us when there's a code problem
can you send those tutorialsl
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
aight, was able to implement moving them the deployed units.
quick question, does OnCollisionEnter2D work if i attach only box colliders onto the two different gameobjects which are colliding or is there something else i need to do
or do i have to use rigidbody2d along with it to make it happen, or is there a better way
if that gameobject has a collider and rigidbody 2d it should fire the event
thanks mate 👍, still got some tuning to do... but i got the fundamentals figured out 🙂
would this be the optimal way to design this here? as in, use colliders and rigidbody to check
that sounds fun to me
but the logic of pick up and drop thing here to remove it seems sensible
aight something very weird is happening, i have set the box collider like this, so when a deployed object is dragged here, it should detect collision and then blast it away, but guess what, whenever the game starts, it just starts dropping out of view all of a sudden
the rigidbody mode was not changed to kinematic
your physics settings must still have gravity so it fell!
best go read about rigidbody 2d and its settings
why does unity say that it works when objects only have the collider2d in here though
should've just gotten rid of /or it seems to me...
I think it means that it is sent to the rigidbody's children that have colliders
ehhh...they just assume people know such stuff i guess then
thats not at all how it works..
they dont build airplanes that any-ole joe can fly.. u gotta learn first
It does say it actually:
Compound colliders (parent Rigidbody2D + child Collider2Ds) receive events on both the parent and the specific child involved.
How does one configure/modify an existing JavaScript library to be utilized by Unity? I know Unity uses .jslib and .jspre, but I do not understand how I modify an existing JavaScript file to conform to those types.
ahh shiiii, another instance of me jumping the gun.
using UnityEngine;
public class ColliderCollisionCheckScript : MonoBehaviour
{
void OnCollisionEnter2D(Collision2D col)
{
Debug.Log("Collision detected.");
Animator BlastAwayMUAHAHAHA = gameObject.GetComponent<Animator>();
BlastAwayMUAHAHAHA.enabled = true;
Destroy(col.gameObject);
}
}
this is the script attached to toothless, it ain't detecting any collisions though...
said gameobjects which should be colliding
i am guessing this is the problem?
assuming both rd2ds are kinematic, then yes that is the problem
oh aight
i tried reading through the rigidbody2d and i don't see any mention of kinematic or static types, so i went to rigidbody documentation and only found this, which basically means that rigidbodies having kinematic type cannot be moved or rotated using unity physics otherwise, they won't be. i don't see any mention of static type though
you're looking at the 3d rigidbody documentation
the functionality and docs differ a bit between the 3d and 2d versions
2d has nothing related to it though...
it's the body type
gee, if only there were clickable links that could tell you more. since they don't exist i guess you're stuck
mb
guys, this blast only ever works once, what do i do. i don't rly want it to loop...but everytime it does collide(after the first collision), it ain't happening again
also, it kinda gets stuck O_O
using UnityEngine;
public class ColliderCollisionCheckScript : MonoBehaviour
{
private void Start()
{
Rigidbody2D rb = gameObject.GetComponent<Rigidbody2D>();
rb.useFullKinematicContacts = true;
}
void OnCollisionEnter2D(Collision2D col)
{
Debug.Log("Collision detected.");
Animator BlastAwayMUAHAHAHA = gameObject.GetComponent<Animator>();
BlastAwayMUAHAHAHA.enabled = true;
Destroy(col.gameObject);
}
}
```this is toothless's current code
if u destroy the collider gameobject what makes u think it'd happen again?
the collider is gone after that eh?
oh wait, toothless loses his collider after one collision or smth?
Destroy(col.gameObject); <-- whatever this is
https://streamable.com/f23p7c My character wants to stick to objects like its a gluetrap with just kinematic movement
ya but i make copies of it cus these are references to a gameobject and i keep making those clones
so.. you could still collider with other copies of the script yae.. b.c they have their own colliders.
but if u meant its not working repetitively its b/c it cant b/c u destroy it..
i think i misunderstood ur issue
i thought you thought that it was the prefab itself which was getting destroyed
oh wait nvm, that's not the problem, the animation is the problem
it only plays once and then stops
oh wait nvm, i might be able to fix it
oh no i didn't assume that b/c u should never be destroying the prefab.. just a specific instance of the prefab
then i misunderstood your statement, what were you asking then?
make sure u deal with that warning u have there
can you share the code?
the collision is happening tho..
u dragged 3 things and 3 collisions happened
so maybe explain the actual problem/issue a bit better.. b/c its not very straightforward
although the three object were destroyed when they were placed in front of toothless, he isn't playing the animation he should be playing all of those times, he only ever plays it the first time
i initially thought it was a problem with collision not being detected but later found out that that was not the case, that is what led to this confusion
did you set the animation exit time to 0, reset the trigger or bool then play that trigger/bool again
just saying, it's read only, so if you think what you are saying is applicable to that, tell me
the animator window
no trigger? how did you play the aniamton
this things
try use the parameter to play it
should i use trigger or bool
i will only call it once, so using bool might not work...
trigger for one time thing
you are missing alot, you have the paremeter on the transition? i can also see you didnt link it back to a emtpty state for it to exit the state to go back into it later
i think you wanna spend like 10min watch a animation tutorial fr
thing is, i do have one set up just like that, i was wondering whether it required a similar implementation or not cus it was read only in this case
it's still not working
another thing, somehow, whenever i ctrl + S, these changes that i made in animator get wiped out
toothless doesn't wanna be animated



yea you put stuff in reverse now
you're doing too much too early.. imho
and the entry link to the animation mean it go into it immediate when spawn doesnt make sense here
but it doesn't rly animate when i play though
like i said you put in reverse rn the arrow going out have the paramter
means when trigger on its exit the anim
you should rewatch
how else is one supposed to learn though...
when the game play you can see the animator in action
try to follow and debug the state flow
alright
i can't even see the flow
the timer thingy doesn't appear
whats the warning there
The referenced script on this Behaviour (Game Object 'Toothless') is missing!
that's weird cus i do have it attached else the objects wouldn't be destroyed on colliding
thats sound very important idk man
also i can see warn about the animtion transtition herer
ain't showing the error anymore though
that error is weird though
theres nothing wrong with learning...
but alls im saying is ur getting ahead of urself.. (imo)
the error was what i pointed out way up top ^
no clue why and what it is.. but def take care of those so u know its not a piece of the puzzle
i don't think i am doing complicated stuff
any ideas as to waht could fix it?
oh
it appears to be an empty reference.. (like when u add a script to a gameobject and delete the script, but forget to remove the script from the object before you delete it)
ya, but like that isn't the case cus how else would objects be destroying themselves...
this sign is weird too
scroll the inspector down. ands ee if theres anything beneath that sript
noo....
this is weird too

i removed the script and bro what
does this make sense or am i trippin honestly
is this outside playmode?
yes
why are you disableing the animator idk man
and now when i ctrl + s, guess what happens, the new states vanish bro what
thats b/c its not removed in the prefab
just the version of it in the scene..
click the arrow on the right of it to open the prefab and remove the broken script from that
i think the missing reference breaks it and doesn't allow you to apply the overrides from the scene..
probs have to do it within the prefab itself to make sure its all good
aight this worked out
and guess what, the animation is working finally but there's still a major problem
if i ctrl + s while not playing the game, these new states are getting wiped out
as in, on ctrl + s, they return to how they originally were
ah shiii, it's too late about 5am here. @rocky canyon and @rugged beacon thx for the help.
pretty sure that plus means you added that script into an instance of the prefab in a scene
without updating the prefabs override
🤔
welp.. 1 step at a time.. atleast u got that sorted
Is there something wrong with my code? My player won’t move I’m legit doing the most basic code movement rn so absolutely nothing crazy : )
Maybe try this, this should sort out your problems
What?
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
at a very high level: x = cos(t) and y = sin(t) trace out a circle
Stop using notepad. It is not suitable for writing code.
What else do I use ? It’s the only thing that pops up for me
You were just linked to some options
Oh I see now, but still I don’t have an option to use another writer
have you considered following the instructions for one of them in the conveniently linked guide
So follow the instructions provided to install them
Oh okay sorry I’ll click and see how to install
also Visual Studio should have already been installed by the hub when you installed the editor unless you specifically went out of your way to prevent it from doing so
I just opened the program for the first time a week ago so everything should be in its place as a beginner download I hope
then just follow the guide for Visual Studio installed via the hub to get it configured
lol, ya, its awesome.. i broke up everything into their separate axis' w/ 2 multipliers for each frequency and amplitude and it makes for a pretty fun fidget toy :D.. w/ the trail renderer i've made all kinds of cool patterns just by tweakin each parameter.. like a lazer lightshow
guys if anyone has the time and is willing to help me out, I kinda need a sniper elite like enemy script that includes, Post points (places where the enemy walks to to lookout for the player), player detection with suspicion and lowered detection if crouched... and shooting etc. thanks!
Ok guys I got the script working but now my player is only moving right and never left when I click both a and d
can you share the movement code?
I would imagine it's because you're either checking if D is pressed and that means you don't check for A, or you're checking for A, assigning the movement, and then checking for D and reassigning it
Sounds like an issue with your code
I copied the code from official sources online so I’m not sure I’ll take a pic tho
Do not take pictures of code
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
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
This is not a place to provide full scripts for you, we can help you with problems and errors but that is as far as it goes
is it normal that when I typed "OnTriggerEnter" it didnt show suggestions?
!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
I want my player character to take damage, but with a damage immunity period of 1 second.
Code:
void Update()
{
if (invulnerable)
{
invulnerableTimer -= Time.deltaTime;
if (invulnerableTimer <= 0)
{
invulnerable = false;
}
}
else
{
invulnerableTimer = GlobalData.instance.invulnerableTime;
}
gameTime = Time.frameCount;
}
private void OnTriggerStay2D(Collider2D collision)
{
if (collision.gameObject.tag == "Enemy")
{
if (invulnerable) return;
Debug.Log("frame: " + gameTime.ToString() + ", invulnerable: " + invulnerable.ToString()); //debug
invulnerable = true;
if (playerHurt != null) playerHurt(this);
}
}```
Result:
Expected behavior: the if(invulnerable) return line and invulnerable = true prevents multiple playerHurt events from happening within a short amount of time
Observed behavior: as shown in the part in the red circle, invulnerable still seems to be treated as false 8 frames after a hit occurs
You should set the invulnurableTimer back to its full value in the same if branch you set invulnurable = false, otherwise bringing up the timer to its full value is delayed by one frame and you might get a 0 frame invulnurability on hit
if you are hit right after invuln ends
Did just that, and then did a few tests, and it seems to work, thanks!
anyone here actually using system.text.json libarary in their project instead of newtonsoft, and was building games for smartphones? i want to know if STJ really that unstable and dangerous if i migrate there
Where are you reading this? We're using System.Text.Json pretty extensively in our AppClip app which does very aggressive code stripping, and never faced any issues with it.
nice, then i gonna migrate to STJ today👍
~~its........google gemini generated result 🥀 ~~
this one , i suppose
Any specific reason you'd want to use it over Newtonsoft Json?
i use STJ on cloudcode code, it works good, and i had heard STJ performs better than newtonsoft for most of the time
a long time actually, so i think its time for me to do it now
if it doesnt really have compatibility issues i dont see the reason not to use it?
So you know, you should get a decently clear exception if some required generic class is missing so you can correct it.
Perhaps STJ attempts to use more generic types than newtonsoft json does
I will say that unless you are dealing with massive json files i doubt there will be much difference perf wise
welp lets see
guys i have an issue when I hit a wall, my character gets pushed back a little when I turn the camera
is it because of character controller parameters or a controller script
its happnening not always
but sometimes
at the fifth second
can someone help me im trying to use blend tree and its bugging and i cant fix it
whats the problem
im trying to use blend tree for walking left anim at -1 speed, idle at 0 speed(i cant put 0 so its 0.01) and walking at 1 speed but the only anim that is using is walking and i alr checked if the speed is -1 and it is
what's blend type of this blend tree?
1D
2d like mario
how im supposed to call 2d thats not topdown?
i just misunderstood cuz u said walking left
as i get u meant walking back
so maybe its issue with parametrs
idk bro😭
private void SetAnimation(float Move)
{
animator.SetFloat("Speed", Move);
if (isGrounded){
if (Move == -1){
transform.localScale = new Vector3(-1, 1, 1);
}
else if(Move == 1){
transform.localScale = new Vector3(1, 1, 1);
}
}
if (!isGrounded)
{
if (rb.velocity.y > 0.1f)
{
animator.Play("Falling");
}
else if (rb.velocity.y < 0.1f)
{
animator.Play("Jumping");
}
return;
}
animations coding
erm
i dont know much but
why u changed
the speed of animation
i did?
maybe for 2d is different but as i know all animations should be at 1
😭
speed
oh
I just dont understand why you changed the speed of animations
chatgpt told me to
when idk what to do i ask him
u putted playback speed at negative
maybe it cause to reverse your animation and make you running left looks like running
right
try to put all playback speed(right column)
at 1
same but it has gotten me stuck currently
the anim its working but now i cant rotate the body to left so dash always go to right
hey i was wondering how silk song made there players and enemy glow white like was it teh sprite changed or just added glow
bloom
i'd suggest googling bloom in 2d unity
will do
Is there a way to detect if two 2D colliders touch, but not overlap? Using Collider2D.Overlap always returns a collider when the collider is in contact with another
i.e. is there a method to detect if two collider2D areas overlap, but not edges?
update: setting the collider's size to 0.99 doesn't work, while setting it to 0.98 made it work correctly
could this potentially be a problem (for example, miniscule differences in physics calculations making it inconsistent)
Physics messages will tell you when they collide but perhaps that's not useful to you here?
well if they collide then they'd never overlap, though that might not be viable for your usecase
I want them to automatically correct errors for every project I write, what utility do I need?
there's not really a tool for that
we can't read your mind, a tool even less
a mistake might be incorrectly written from a ton of things
I mean it will show a warning as soon as it is written wrong in any way
Do you not already get red squigglies if you mistype something?
How do I use visual scripting? I just found about it rn
I did not receive any warning
!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
There's nothing wrong in that screenshot. What warning did you expect to see?
You may want to ask the #1390346878394040320 channel/server.
Q: Is there a way, to get the cursors position any maybe freeze it?
Yes you can do both - but what's the end goal? Just a locked cursor like in any FPS game? or something else?
Cursor.lockState
not sure if this is a correct section, but I am having some issue with NavMesh agent always hugging the edge of the NavMesh Surface and they end up getting stuck. Anyone know if there's a solution so they stay away from the edge and stay more close to the middle?
damn that gif export was pretty bad
ah there it is, thank you
Hi, question. which best: script movement or Root- motion?
Define 'best'
and,
what best plan/code to make, Animation doesn't interrupt each other especially you had idle, Walk, run, and attack
If you are using mecanim, you can set when and whether aninations will interrupt each other.
I don't have vision future problem, when I facing, slope, stairs, and ragdolls
Ragdolls would be separate entirely where you wouldnt have any animations controlling its movement
Controlling the movement by script will give you the most control.
is your collider set to "isTrigger"
and does your Player have the Player tag
and you need two colliders, one for the door and one for the player and a rigidbody involved, other than that it looks ok to me
It would be better to use an animator bool and 4 animations (opening, open, closing, closed)
use Debug.Logs to find out where the problem is.
Or use just an open and closed state and let the transition do the "opening" and "closing"
how
inside the OnTrigger use Debug.Log("works");
ye
put it at the spot where you expect something to happen
oh wait i see the problem, the script is not on the door but on the player?
in the empty
"create empty" is just a gameobject without any existing components. once you add stuff, it's no longer empty
game object well yh
put the script on the door
and do not cross post please
Im really lost on this chat, I use the same animator as the tutorial timmy bot does. I just changed the code. I can freely move (besides jump) at any direction I want. So the movement is fine, its just the animation of it, im guessing its the animator. So I dont know what to do lol, do I need to change the code again so it will suit the animator? or change it animator so it will suit the code? id appreciate all the help. (I can paste the code in dms if anything, its just 70 lines long)
Dm
bet
you are not following any instructions, please scroll up and read carefully what was suggested.
i meant like... a cursor that not just freezed, but also visible. its like roblox, where the cursor freezes if u press rightclick. then u can like look around.
can u write for me instructions so i can follow it if u want ofc thank you
Would anyone be willing to help me add proper local co op to my game? Im an extremely new dev and I know its a lot to ask but as of right now my game is still very simple and based on a tutorial. I added a few things to it myself and help of other tutorials but it would benifit so much from co op. I attempted to do it myself but came to realize I wont be able to without lots of help.
co op is a really vague term, it can mean many things, please ask something specific
Okay, I have a top down 2d waved based shooter I am working on. Currently you can walk around, shoot zombies and die. I would like to add in a drop in system that automaticly adds in another player when a new input device is used (Ex. a controller). I need the new player to have separate stats for everything like health, money, damage, fire rate, etc that I can modify using a shop system I plan to add later. I also need it to add a new UI for the new player that joins in so they can tell how much health and money they have.
Currently my code is based off of a tutorial on Youtube that I assume wrote the code I'm using to only work with single player so I probably have to re write or modify a few scripts (Or a lot)
does anyone maybe know why my enemy spins around the player when they're close to them instead of trying to move straight through them like you'd expect?
Most likely because they're trying to stand on the same spot as the player, bumping into them, and then "steering" around in your handleRotationto try to face the player while simultaneously moving in their forward direction.
You probably want to give your enemies a point they can actually reach (adjacent to the player), and then increase their rotation/steering so that they don't "drift" past it if they're going fast.
Cursor.lockState is what you want
you mean you lock the cursor in the position hes in and with the right mouse you move around the camera?
oh nevermind you got answered
can somebody help me i cant figured out what to do
so i made a folder in my assets named scripts i opened the folder and the tutorial was watching the guy right clicks inside where is it says This folder is empty then he goes to create and makes a thing called a c# but for me when i do that there's ever thing in the create menu expect for c#
you literally asked this, got it answered and said thanks
it ended up not working
which tutorial is that exactly
i find the link rn
The first video in a series where we are creating a First Person game!
In this video we look at setting up our characters movement.
I've setup a Discord!!! and I would love to have you help me start up a friendly community where we can all help each other grow as game developers!
Discord invite link:
https://discord.gg/xgKpxhEyzZ
Can't wait t...
what specifically is not working
i opened it and some of the text on his screen is different like he has 3 lines that say using Unity... but i only have two and when i type exactly what he dose his turns usually green while mine stays white
the template probably changed, that's not a big deal. as for the colors, you are probably using an unconfigured IDE
!IDE
the tutorials is 3 years old
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
so should i use a different tutorial
no
no, you should configure your IDE
i am watching your tut but nowhere in the video can i find where he adds "new c#" as you said
its at about 7:20
it's at 7:24 where they select the "C# Script" option from the create menu which has just been renamed (and they were already informed about)
ya
yep read the bot message on how to configure your IDE, this is a really important step, otherise you will miss a few functions such as auto code suggestions (intelisense)
it teleports the cursor to the screenmiddle tho.
Does it matter?
If it's locked you can't click on stuff anyway, right?
If you really need something else you can save the position before you lock it, then when you unlock it you can warp it back to that position
unity removed this function
am using unity6
it is meant for better control
Unity didn't remove any functionality in Unity 6.
nvm i google it. it has nothing to do with cursor but with input. thanks for trna help me tho
"You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings" unity keeps telling me this. idk how to get around it should i change it? when i go to change it unity tells me it prefers i leave it alone for newer projects
and idk what the pros and cons of changing it are
You can switch to both enabled without any cons(well there is the price for having both packages in the build, but that's about it).
Or switch to the one you're actually using in your project. No cons at all.
For future reference, I recommend checking the documentation and reading about the different input systems.
okay thank you
I Need a help,
I Buy this unity assets https://assetstore.unity.com/packages/templates/packs/stack-cube-270025 why when i play demo look like pink lie this ?
Magenta means you're looking at a material that is invalid for some reason. The most common reason being it's using a shader that's intended for a different render pipeline than the one you're using
Most likely the demo was made for BiRP and you're using URP, or HDRP. Something like that
Either way
this is not a code question
how common are straight up app rip offs on the asset store 🤔
Okay thank you,.. I got a project to make an simple game.
So I buy an assets.
Technically u are modifying a base game rather than making from scratch
How is aim cone / aim spread typically done in a first person shooter?
I see a lot of posts saying to do Random.Insideunitcircle which returns a Vector2, which they add to the 3D forward vector, but that just doesn't sound right at all, given how 3d vectors work... you'll get funky behavior when looking at different axes of the world, no?
Create a random rotation with Quaternion.Euler and rotate your aim vector with it
How do I get over the boredom of learning how to code?
You switch to a hobby that interests you? 😬
-_(..)/- Well I wanna be able to make games.
Its just watching tutorials that I find boring. I never written any of my own code before.
have you tried other tutorials?
sometimes some formats just don't work for different people
is there a way to make the camera pan to a sprite in game view
I was trying smthg and zoomed around to much and now I cant find it
If you have no interesting in coding at all, you can try the followings:
1 - Node base programming: no code involved, drag n' drop stuffs. Notable choices: Unity Visual Scripting, Playmaker, Odin Inspector (on asset store).
2 - Vibe coding: let AI do the hard work. But your hard work is guide the AI to do what you want.
3 - Hire freelancer or ask someone to join your projects.
would not recommend 2 at all. that just creates more work for you to fix broken shit in the future
also for 1, you still need to learn how to code
Learn how to program more likely
(in general) there's 3 major parts to programming:
- Language - The syntax, structure, and paradigm of each language
- Library - The interfaces and utilities that each environment or toolset provides
- Logic - The algorithms to do work at runtime
Logic is almost completely transferrable between each language and environment, you just have to learn the specific Language and Library that you're using
Language is also shared quite a bit between languagesof course, learning 1 part at a time is easier than learning everything at once, which is why tools like scratch or code.org are popular as coding courses for beginners, especially kids, because it only focuses on the Logic aspect
It is not easy, but it is rewarding. U don't have to make something too impressive in the beginning. Just start off easy, and u will find enjoyment in completing simple tasks
Where would I go to find some people who would want to work on my projects? Any website suggestions?
!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**
Free or paid?
If it is free, you can join some game jams, make friends and ask them to join your projects; or you can ask on Collaboration on Unity Forum, or some Unity related servers on Discord.
Things are easier when it is paid!
I think the hard part is watching a course and watching previous lessons on things that I forget and eventually getting burned out and losing motivation
Taking notes helps. At the end of the day, instead of rewatching tutorials, u will have a short list of important lessons to review
if you don't apply what you've learned, you'll eventually forget it. generally working/following along with tutorials will be more productive than just binging a playlist
Hi, my console messages get stacked instead of sending individual messages (see the numbers on the right)
how do I change it back to like before
"collapse" toggle
oooh thank you so much!
GUYS i really need help
i have a blend tree for walking and idle that is working but for any reason the game only play my falling animation non stop
#🏃┃animation no code question
fine can you help?
Nope, no time, but the channel got some peeps that can
ok thx
can someone help me please , i start unity today and im blocked with something in my scene
!ask
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #🌱┃start-here
euh i don't understand
we can't help without more info about what the issue is
Ahhh, well basically I have a problem with my scene in Unity. I followed a tutorial to make a Raycasting system, but now I'm having an issue with the controls.
I made this script (which depends on another one):
using UnityEngine;
public class OpenChest : MonoBehaviour
{
[SerializeField] float internalDistance;
[SerializeField] bool chestOpen = false;
[SerializeField] GameObject chest;
void Update()
{
internalDistance = Raycasting.distanceFromTarget;
if (chestOpen == false && internalDistance < 2)
{
if (Input.GetKeyDown(KeyCode.E))
{
chestOpen = true;
chest.GetComponent<Animator>().Play("DoorOpen");
}
}
}
}
But when I run it, I get this error:
InvalidOperationException: You are trying to read Input using the UnityEngine.Input class,
but you have switched active Input handling to Input System package in Player Settings.
UnityEngine.Input.GetKeyDown (UnityEngine.KeyCode key)
OpenChest.Update () (at Assets/Scripts/OpenDoor.cs:14)
I am having some trouble with my custom UI , in particular my "UnitCards" are overlapping and not displaying in the correct location , anyone able to take a look at the setup briefly? much appreciated

