#💻┃code-beginner
1 messages · Page 718 of 1
bap? curved thingies?
if you are raycasting from the rigidbody directly to the collision why would something be in it's path?
like so
because i would prob raycast from player feet towards object
use a layer mask
huh?

please explain
no i need you to im lost on what you are getting at
also it explains here https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Physics.Raycast.html
i showed a slope on the map
lemme show in editor
even worse
i made a map 1 obj file
i've got no clue at what i am meant to be looking at
on the left is the slope i showed you
on the right its origin
so in that case i wont be able to get its normal via raycast
if you are trying to get the normal of something that is expected to always be below you why not just send the raycast down?
because i need to get collisions
i dont except for it to be below
nothing is stopping you from getting collisions what
how do i get them then
you mentioned this is to be from the feet, and you mentioned slopes so why would the raycast go any other way but down?
right you get that with the fucking raycast
or this, not that i would recommend this way since it's based off the first contact which could be off
ContactPoint contact = collision.contacts[0];
// Rotate the object so that the y-axis faces along the normal of the surface
Quaternion rot = Quaternion.FromToRotation(Vector3.up, contact.normal);
which is shown in that link i sent, read.
oh fuck im so dumb lmao
srry
but one more question: how to check collision in update

you dont
unless you make a instance variable but then even after you aren't touching the object it'll still be set as that collision
why
cause OnCollisionEnter is called when a collision is detected it has no relation to Update();
how can i limit those collisiosns to one
you dont what?
otherwise there will be some bugs when 2 objects touch player at the same time
this feels like the https://xyproblem.info/ where you are omitting info
okay
i want to make playercontroller like in https://github.com/vectozavr/shooter, and it has jumps like that: it checks if player has collisions
And if it has, and space is pressed, it adds vertical velocity that is calculated by multiplying jump force on dot product of collision normal and vector pointing up
But if it equals zero, it will do the same equation but instead of dot product it will put deltatime
So that results in a really funny controller that allows you to climb, slopeboost, etc
And also those features were a result of a bug
Was that enough explaination?
i would think that odds are u wouldnt get two OnCollisions at the exact same frame..
soo maybe use like a cooldown timer after that first collision to not the code to run again for X amount of seconds or something
also "states" come to mind.. if ur in this state allow this.. if ur in that state dont allow this.. etc
The thing is i need to check for collisions every frame
Thats why
And i asked because you can stand on the floor, bump into corner and get even 3 collisions
is there any way to delete all the players in unity cloud the easy way?
not at the moment
I have a small client to facilitate such things, if you're still interested I can send it to you (when its done)
kinda sad that after many posts I made on forums the current web interface is pretty underwhelming with missing features requested long ago
can you send me code ? I'll add it to my game's admin panel
or api
oh nice found it
DeleteAccountAsync()
checkin for collisions every single update frame would be hella expensive
thats y collisions/physics happen in fixedupdate (which is a slower but fixed frame)
physics can be accurate b/c of it having that fixed timestep..
you could change the physics step in the settings to match the Update() if you also locked your framerate.. but thats just silly
so now im also assumin this is an x/y problem and what u think u should have happen doesn't actually work that way.. and(or) theres a more simple standard solution to ur problem
i also misunderstood what u were asking originally mb
yeah just iterate basically
I found out why the speed is being reduced
There is an issue... I have 180hz monitor, so physics locked to 60 tps is really god-awful
because of lerp
I didn't really understand why, but I know it's because of this
its probably used incorrectly
I remember that in gmod (tickrate is 64 by default), if i make a box, and throw smth in, it will act weridly, because physics is delayed by 3 frames at worst
And if that delay would happen on jumps many frustration would appear
My first mesh 😛
I dont really know why the texture dont fit all the mesh, the image is only the apple :c
Hi, I'm trying to make sure that my wheels have a rotation but nothing did, the front vehicle backs up etc but the visual physics doesn't work
And what is car controller doing 
The code?
Yeah hard to tell whats going on from those pictures
Now my mesh and texture are working 👏👏
Hi I am I right in thinking with cinemachine i do not need to attached a script to the main camera. Could I ask with cinemachine how do I fine out what the issue is or can I add script to the cinemachine. I have checked and I am following the correct target because the cinemachine rotates and looks where the object is going but does not follow it.
theres a lot of different settings and camera options, you would just need to go through the docs or tutorials to find out how to use it properly. theres also #🎥┃cinemachine
i cant find a way to make an rocket launcher does someone know how?
is there any other way to prevent
No measure function set in this node's config
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
spam in 6000.2 besides restarting the editor?
this is a poor question, ask about what issues you had instead
my issues were that when i put my gun.cs on my rocketlauncher the game didnt work anymore
now i lost all the codes due to a mistake lol
version control 🤦
version control?
most likely because you had a bunch of errors
i had 0 errors when i checked
maybe it was a bug or sm
im just gonna try an other way of making it
git, cvs, etc
ohh ye
!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.
is here
see below
!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.
what ??
can anyone help me please: What is wrong with this (its the newest Unity Version)
private IEnumerator DarknessEvent()
{
Light[] sceneLights = FindObjectsByType<Light>();
float duration = 10f;
float elapsed = 0f;
foreach (var light in sceneLights)
light.intensity = 0f;
while (elapsed < duration)
{
float randomTime = Random.Range(0.1f, 0.5f);
yield return new WaitForSeconds(randomTime);
if (sceneLights.Length > 0)
{
Light l = sceneLights[Random.Range(0, sceneLights.Length)];
float originalIntensity = l.intensity;
l.intensity = 1.5f;
yield return new WaitForSeconds(0.1f);
l.intensity = 0f;
}
elapsed += randomTime;
}
}
whats wrong with it
It cant find the lights
use a serialized list instead?
what does that mean
Wait, I am stupid, they are 2d lights
I will, thanks
post your code appropriately as the bot says
A tool for sharing your source code with the world!
so what was the issue again?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 5f;
public float jumpForce = 10f;
public bool canJump = false;
public bool canClimb = false;
private Vector2 movement;
private Rigidbody2D rb;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
movement.x = Input.GetAxisRaw("Horizontal");
if (canClimb){
movement.y = Input.GetAxisRaw("Vertical");
}
if (Input.GetButtonDown("Jump") && canJump){
Vector2 jumpVector = new Vector2(0, jumpForce);
rb.AddForce(jumpVector, ForceMode2D.Impulse);
}
}
void FixedUpdate()
{
if (!canClimb){
rb.velocity = new Vector2(movement.x * moveSpeed, rb.velocity.y);
}
else {
rb.velocity = new Vector2(movement.x * moveSpeed, movement.y * moveSpeed);
}
}
void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.CompareTag("Ground")){
canJump = true;
}
else if (other.gameObject.CompareTag("Death")){
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
else if (other.gameObject.CompareTag("Ladder")){
rb.gravityScale = 0;
rb.material.Friction = 10;
}
}
void OnCollisionExit2D(Collision2D other)
{
if (other.gameObject.CompareTag("Ground")){
canJump = false;
}
else if (other.gameObject.CompareTag("Ladder")){
rb.gravityScale = 8;
rb.material.Friction = 0;
}
}
}
why i can't change the rb.material ? it's a physical material
rigidbodies don't have materials
they have physics materials
colliders do
oh right, so the problem is "my code doesnt compile"? or what
so what to do
what have you tried to do so far
was this ai generated or you just tried to guess what to do?
what have you tried to do to solve the problem*
Can i Say that cursor and other similar AI assisted code creations tools are so nice tò have in 2025 i can code much more and much faster than i ever could even if i was a senior
Before we have to sit through the inevitable "AI is just a tool" and "just wait a few more years and it'll do everything" discussions, we have a thread for AI
https://discord.com/channels/489222168727519232/1352599815770341479
Nice ok, Sorry i didnt know there was a thread about It, thx
hello is there a way to detect collisions without making the object push eachother?
Kinematic rigid body ig?
whats the collision then
no then they wont detect collisions they have to be dynamic apparently
wdym?
"detect collisions" is pretty vague. what are you trying to do
its between two objects and i only want the collision to be detected, not for them to push eachother
use trigger colliders?
Trigger colliders should do the trick
im trying to make objects see if they have collided without pushing eachoter?
alr ima look into what trigger colliders are
Just a check on the collider
thanks!!
Trigger on Collider should be checked
the is trigger button?
Where can I find games that I can access the editor and dive in and see how things work
none really
legally
I Guess on unity learn
theres some open source projects but not like fully finished notable ones
Yeah most likely
the minigame templates are cool to look thru
Ye what i was thinking about for already made projects on unity
!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.
there isnt a channel for bot commands right?
there isn't, no
would be a bit pointless since the commands are meant to direct other people to resources
ok just wanted to be sure
anyway collisions are not being detected now that i changed to trigger colliders
on row 39
that makes sense, trigger colliders don't collide
yes but isnt it supposed to realize that it has been triggered when the collider makes contact with another game object?
have you gone through the steps in the link i posted
why do this code
_rb.MoveRotation(Quaternion.Euler(0, Input.GetAxisRaw("Mouse X")*_sensitivity*Time.deltaTime, 0));
rotates my player around X axis, not Y?
oh it's a trigger message
we are not standing over your shoulder
sorry i missed it ill go through it
this rotates around the Y axis
that's very little info to go off of
unity dont think so
also, don't multiply mouse delta by deltaTime
prove it
ok
imma just be blunt, you're probably reading it wrong
1 sec
also note that that's basically an assignment - "set the rotation to X" rather than "rotate by X"
but it atleast should work i guess?
use mp4 not mkv to embed in discord
ok
whats the best way to get* different values based on if it's left, top left, right etc. i.e left = 0 topleft 1. need need the value to lerp between each other too.
huh send values where?
still doesn't make sense.. this question is incomplete
get values from where?
it sounds like you're asking about representing directions
in which case, well, direction vectors?
ok i'll give you more context i have a synth in unity that needs different frequencies based on the player's joystick.
so Inputs ?
ye.
are you using the new input system ?
i removed deltatime and it just got worse
yes.
you should have a 2D composite that gives you. a V2
you need to lower the sensitivity to compensate
@slender nymph i went through the steps and i still cant understand why it isnt working
sens is 1f huh?
i call it in update
show both objects inspectors
yes. i would use that to set different frequencies but it doesn't have stuff for corners.
you sure about that? check the inspector
sure it does, it returns v2.
if its for example V2 ( 1, 1) thats top right .etc
and afaik if you wont do that, camera controls will become fps dependent
yeah but how would i convert those values into what i want i cant do a lerp or if with that.
mouse delta is already per frame, it's already frame-independant
if you multiply deltaTime in, it makes it frame-dependant
wrong, camera controls become dependent on fps when multiplied by deltaTime because they are already frame independent
https://unity.huh.how/mouse-input-and-deltatime
you could get the direction as an angle, maybe
that is something that you should have checked when going through the steps in the link
but that would have a jump when it goes 360°
if the rb's rotation is frozen, wouldn't you be rotating the transform? would the rb not cede control over rotation in that case?
do some type of mapping , possibly a switch.. What kind of value range do you want from it ?
sorry i found the "i am still not getting a message" button now that you said it
0_0 srry my mistake
i need very specific for left, right, up-right. for the 8 notes in a c scale.
📃 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.
some type of collection , list or dictionary should probably suffice
A tool for sharing your source code with the world!
pass the V2 and get some values
any ideas why player spins around X and not Y?
of if the output doesn't have to be continuous then you probably could just get the direction as an angle and round it to steps of 45°
how would this work for continuous/analog inputs
arent they looking to map a direction to specific frequency value
a direction taken from joystick input
yeah thinking some type of mapping
this'll work thx. i should of thought of it.
show the inspector + scene of objects involved
Are you sure that the _head variable is not referring to this GameObject?
0_0
how i missed that?
Well you forgot to look at the only lines of code that actually do rotate things around the X axis
yea im dumb
btw MovePosition is usually used for Kinematic
https://docs.unity3d.com/ScriptReference/Rigidbody.MovePosition.html
evn the docs says so
"Moves the kinematic Rigidbody towards position."
anything Physics related should also be in FixedUpdate
guys i use Destroy(gameObject); and some objects wprk but others say Destroying assets is not permitted to avoid data loss
you still didn't post what was requested
huh
like i just instantiate a prefab and the instance tries to destroy itself but it gives the rror message how do i delete the instance
bro its just like 3 lines
you are probably not deleting the instance / running the code off the prefab
why would i post the whole code
Because we can't tell what's wrong with your code without seeing it
its called Context
ok rude
You're trying to destroy a prefab. Why and how? We can't tell without seeing the code
The unwanted behavior probably is related to the other lines of code
whats called first: oncollisionstay or update?
this is * though with manually calculated physics updates though right
its in fixedupdate in the slice attack part
How to post !code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
huh ?
sorry its early morn for me lol my brain still not functioning
they are called in different loops
oncollisionstay is called in the fixed time step
update is called per frame
ya, i said this yesterday.. they're confusing how collisions occur..
they were wanting every frame collisions yesterday iirc
xy
oh lord
Why is everything public and what's the point of a placeholder object? Make it private GameObject instantiatedCheeseSliceShadow; and check for null instead of a placeholder
i mean what will be called first: ocs loop or update?
btw like most things, you can easily test this with some logs
isn't that the whole point of development too ? trial and error to see how results play out
please dont judge me im a beginner and later when im done im gonna check what should be public or private
spring joint docs. Why is the second sentence in each of them the same
btw you should post it via links linked above, having to download a file is cumbersome
Frame 1: Update()
Frame 2: Update()
Frame 3: Update(), FixedUpdate()
Frame 4: Update()
Frame 5: Update()
Frame 6: Update(), FixedUpdate()
Frame 7: Update()
Frame 8: Update()
Frame 9: Update(), FixedUpdate()
Frame 10: Update()
Frame 11: Update()
Frame 21: Update(), FixedUpdate()
``` Update and Physics kinda happen like this
OnCollisionEnter, OnCollisionStay, and OnCollisionExit are all ran immediately after the physics step, which itself happens inside the FixedUpdate cycle.
The judgement is just part of life, if your willing to learn we're happy to explain
ik ik im gonna fix it later
this question just does not make sense
i feel like this is slightly misleading
If it's public there's a chance you've dragged a prefab to the field by mistake. Change it now and see if that fixes it
slightly.. lol theres lots more stuff inbetween and more often
but its the gist of it..
throw a 40ms lag spike in there and suddenly you have 2 FixedUpdates back-to-back
lol.. very true.
it may as well be random which is "called first"
no its empty in the inspector
Doesn't matter
u mean between update/fixed?
this means you're trying to destroy a prefab, what you need to do is call Instantiate and use that to do your things and destroy it instead of the original prefab
yeah
ahh gotcha.. ya in the grand scheme of things ive never really thought bout it
it didnt work
Then put Debug.Log($"Trying to destroy {instantiatedCheeseSliceShadow.name}"); before the destroy and see what it logs right before the error
i think this is a carry-on from yesterday..
#💻┃code-beginner message
The thing is i need to check for collisions every frame
And i asked because you can stand on the floor, bump into corner and get even 3 collisions
u can see more context from OP.. even if still kinda vague-sh
yeah definitely an x/y problem
@rocky heart
according to the naming of your variables, you want to instantiate the placeholder 3 times? In that case you're doing it wrong
just assigning it to placeholderObject does not create a copy it's a direct reference. You need to assign Object.Instantiate(placeholderObject) and then it becomes a copy of the placeholder object
otherwise when you call Destroy(instantiatedSkateboardAttack) it is trying to destroy the original placeholderObject which if it is a prefab is not allowed
good catch ^ ur reassgining it most likly
I don't know what's the deal with the placeholder objects but there's a check before the destroy that makes sure it's not the placeholder
It might be related sure
wait why does it say Trying to destroy CheeseSlice1Shadow and not instantiatedCheeseSlice
huh
It's printing the name of the object, not the name of the variable
nice
Comparison is ==. This sets the value to the prefab
it is lowkey dumb that that can be valid code
Yeah I don't understand why it's allowed
or at the very least not insanely warned by vs
assignment is an expression that yields the rhs
and it's allowed since the rhs is a UnityEngine.Object which has an implicit boolean conversion
I made this handy little helper for debug logging https://gist.github.com/ShacharWeis/1e654da40611d040c429e7b7d3441cfd
This might be a loaded newbie question, but how do I go from not knowing very much at all about coding, to making an RPG style game in unity?
The programming class I took in high school was a joke
RPG is def not what you want to start with
Probably a simple platformer first?
sure , anything with simple logic / not a lot of moving parts
want to learn programming? do that, then come back to learning unity and using your new skills
I don’t much care for programming outside of game dev
You still need the basics
Could probably get away with the basics
basic syntax, basic types, functions, collections, yada yada stuff like that
anything unity related is the API itself and a few core concepts you need to know like "what are gameobjects? components? " etc.
Yea you still need those skills to make a good complex game
Game development is more than just programming but will require some level of programming if you're wanting more features
It is but if you cant actually code the logic it wont work
I see, and this is learnable online? Should I take a class?
Oh, the very basics are necessary. Who knows when you're going to have to debug a future game bug later
anywhere you want but imo the best source is the M$ site on learn (pinned in this channel)
You will learn basic stuff you need like store values in variables etc.
w3schools is okay too sometimes for quicker stuff
https://dotnet.microsoft.com/en-us/learn/csharp (from microsoft, maintainers of c#)
https://www.codecademy.com/learn/learn-c-sharp
https://www.w3schools.com/cs/index.php
id go top down myself
Oh awesome thanks yall
oh also coursera too has some good stuff from microsoft https://www.coursera.org/learn/introduction-to-programming-with-c-sharp
hey im having an issue where it says "The name "MouseX" does not exist in current context"
ive been on this for a little while and couldnt find out what it is wrong could someone help me out?
public class CameraController : MonoBehaviour
{
public Transform transform;
public float MouseSens = 2f;
void Start()
{
}
void Update()
{
MouseX = (Input.GetAxis("Mouse X"));
transform.Rotate = MouseX * Time.deltaTime* MouseSens;
}
}
float MouseX =
please do correct me on any bad practices i would be thankful
don't use deltaTime on mouse delta
you need to declare the type to define a new variable
it's already per-frame
god damn it thank you so much
c# basics time!
bad practice is having an empty Start method
oh right sorry
it was going to be filled with a mouse lock
how do i get the name of a textasset
Pretty harmless
.name
still a bad practice 😄
would that also get the file extension?
it exists on all UnityEngine.Object types and should just be the name
so no need to do anything to it
how do i make it a 360 range as Mathf.Atan2(y, x) * Mathf.Rad2Deg; has -90 for down.
why? using it with Quaternion.Euler() is fine
(they want a linear range for mapping onto a different range)
im not sure that's really an issue though. you could just offset it
yea +180 would push it to 0-360
another dumb question bc im bad at cs, im from godot, let
s say i have a function called like
pause game, and i want it to be accessed from any script, would that be one of those singleton things or a public void
those are separate concepts
singleton means the instance is easily retreivable
being public means the member is legally accessible
also, no such thing as a public void - that'd be a public method that returns void
ye ik i was just saying it
it doesn't make sense
Perhaps too pedantic for a beginner channel
You can use a "singleton" static field to access some component with a Pause() function or have the Pause() function be static itself.
wdym too pedantic lol
this is a common misconception
well we can tell they mean a public function, weakly typed langs dont teach people these things well
it's also a common correction here... it's not a pedantic thing at all, it's a basic concept where the term happens to not be a keyword
You would need a reference to the instance to access anything related to an instance. The static keyword used with the Singleton pattern makes use of an Instance variable being a part of the class (not a part of instances of the class) thus accessible from anywhere the class is accessible - declared as static.
Not sure why you're wanting global-like members for. Hopefully not because you're wanting to avoid proper referencing.
No I just don’t know what singletons are in CS
issues with gain in my script.
i was following https://www.youtube.com/watch?v=GqHFGMy_51c&t=57s
and realized that when changing the gain it'll pop even if i smooth out the volume.
video (c) 2016 Prismic Studios LLC
Check out my game on Steam!
http://store.steampowered.com/app/406220/
some code from: http://www.develop-online.net/tools-and-tech/procedural-audio-with-unity/0117433
if I destroy an object thats in a list, will the corresponding entry in the list also be removed?
no
no magic like that exists, you would need to set up something to remove the object from the list when its destroyed
Or you just check for destroyed items when looping over the list and remove them as you encounter them
rn I have private void Update() { for (int i = EffectsList.Count - 1; i >= 0; i--) { if (EffectsList[i].effectDuration <= Time.time) { StopEffect(EffectsList[i]); EffectsList.RemoveAt(i); } } } where StopEffect() destroys the object, so that should be fine right?
Oh well you are removing it right after so no problems there
BUT I thought what EffectsList held was not a component? The unity concept of "Destroying" is only applicable there
Your iteration may become off though Nevermind, reverse loop
It holds the effect objects, mainly to easily check their timers in Update
it's going backwards
it seems to be working though
yea because you removed it from the list so its gonezo
perhaps you are confused about something?
does it just stay in memory forever in this case? I didn't get an error message with destroy or anything
there's kinda 2 layers to it
GC takes care of it 🧹
in other words the Destroy is superfluous if I just remove it from the list?
"oh look nothing references this object i will delete it now!" -GC
Destroy() is for Gameobjects, monobehaviours, components and unity assets only
using it on another class/type does nothing
Does the effect object require you to dispose of it?
there's a c++ layer that unity manages, and there's a c# layer that the runtime manages
c++ memory is handled manually, c# has automatic memory management
UnityEngine.Objects are basically wrappers to the actual objects in c++ land
when you Destroy an object, the c++ version gets destroyed, and the wrapper becomes invalidated, but not magically destroyed
actually, the objects inherit from monobehaviour so I can use InvokeRepeating
If it's a plain c# object, it'll be collected by the garage collector - eventually.
the c# version gets destroyed when the GC notices that nothing's referencing it
if it's still in the list, that wrapper is still being referenced, and it won't get collected
If they are attached to a GameObject then yes Destroy() will do something (remove it from that gameobject)
use coroutines instead
much more flexible and you can actually manage them
BUT you will need to "start" the coroutine from a monobehaviour
same for InvokeRepeating, so i don't see the issue
...same for StartCoroutine?
no we can start a coroutine and pass the returned IEnumerator from anywhere
if we used the function name then that does not work
im not sure what you're talking about
"returned IEnumerator"?
StartCoroutine takes an IEnumerator
with the joystick to angle to 45 degree increments it has issue when round values near 360 i want it to round back to 0.
and not using the function name is a good thing, actually
StartCoroutine(genericClass.Thingy())
What currently happens instead?
StartCoroutine and InvokeRepeating are both non-static, public methods of MonoBehaviour
i honestly have no idea what you're trying to say
check if it's 360 and if it is set it to 0
The "coroutine" function does not need to be a member of the instance we call StartCoroutine() on if we use public Coroutine StartCoroutine(IEnumerator routine);
that is the exception and the other overloads do not work this way due to just taking a method name.
is it a big disadvantage to use InvokeRepeating?
well its not that great and is probably acting as a crutch for you rn
mainly it's for dealing x damage every y seconds
you could call a function on your effects each Update() and implement the same functionality
i forgot Coroutine had a string overload ngl
we did discuss this like 1 day ago 😐
so what was this about..?
this sounded like you were saying coroutine was worse
Nah it was in relation to if effect object is changed to not inherit from MonoBehaviour
but that would apply for InvokeRepeating too in that case
yea
were you not replying to this?
the point was you can still use coroutines without MonoBehaviour blah blah that overload blah blah
anyway im done 👋
ok thanks
bro can someone help me , i just started to learn how to make 2D game ( im new ) and i want to know how can i make light additive and that not everything goes black when i put a light , like if they adds up
how could i do a mathf.movetowards with duration rather than speed i already tried
var val2 = Mathf.Movetowards(val * Time.deltatime)```
this is the code channel
ask #1390346776804069396 or #🖼️┃2d-tools
ok thx
what's the 60f supposed to be
also MoveTowards is not spelled like that and it takes 3 parameters
is your ide configured
i just got this from https://stackoverflow.com/questions/51165278/use-movetowards-with-duration-instead-of-speed
you took it from the question instead of the answer
sry, i didn't copy and paste my code i just typed it.
yeah don't do that
that'll just introduce new problems or obscure existing ones
what's your actual code
var val1 = Mathf.Abs(start - end) / (Duration * 60f);
var val2 = Mathf.MoveTowards(start, end, val1 * Time.deltaTime);
That doesn't look like it'll compile.. 
btw it was after the edit.
why wouldn't it
doesn't really change it
the guy asking is typically not the person who knows everything
isnt it val1 inside move towards
sorry i was renaming my variables to be clearer.
what did you name them for yourself?
oh my god show your actual code instead of changing random stuff that breaks or fixes it
var diff = Mathf.Abs(frequency - freq) / (SlideDuration * 60f);
frequency = Mathf.MoveTowards(frequency, frequencies[targetFreq], diff * Time.deltaTime);
it's best to name your variables so its always clear
there we go
they are, in context.
you weren't even feeding a new value to movetowards before
val1 and val2 are very unclear
so what's the 60f supposed to represent
is SlideDuration supposed to be in minutes or something
seconds also i got the code from https://stackoverflow.com/questions/51165278/use-movetowards-with-duration-instead-of-speed
also that's recomputing the difference every time, so you end up with a smaller distance covered each time - you'd have to pre-compute the time
then the *60 just does not make sense
stackoverflow questions are not particularly good places to get code from
what does duration instead of speed even mean
I'm not entirely sure what you're trying to do but if you're just trying to progress one value to another over time rather than some incremental speed, you could opt for lerp instead.. https://docs.unity3d.com/ScriptReference/Mathf.Lerp.html
Where duration would be normalized
the parameter input being duration instead of speed
i.e if speed is 1 unit per second, then to go from 0 to 1 will take 1 second then if its 0 to 10 it,ll take 10 seconds. i want to calulate a speed that no matter the distance it'll take the same amount of time.
Where the third argument would be something like.. elapsedTime/duration
(which is what they're trying to do lol)
well speed = distance / time, so time = distance / speed
the issue here is they're recomputing speed with the new value of distance every frame
you have to somewhat keep a state anyways
lerp would probably be easier, but that might not support their usecase 
what should happen if a new note is selected before you're done transitioning to the previous one?
i need a nice linear interpolation rather than something like a lerp where it gets slower and slower.
then just calculate the distance once
Linear interpolation is the definition of lerp.
It doesn't get slower if you're using proper lerp
it gets slower if you keep recalculating with shrinking distance
then you get a curve
May as well go for slerp at that point
mathf doesn't have slerp.
you are using wronglerp
You aren't wanting a slerp pattern as far as I'm aware
you need to use actual lerp
You're wanting the proper lerp
how would that help
Applying lerp so that it produces smooth, imperfect movement towards a target value.
We were joking - relative to improper lerp
completely missed it lol
any ideas?
cause Mathf.Abs(frequency - freq) / (SlideDuration / 100f); works fine for me but i just want it in seconds.
Proper lerp
https://unity.huh.how/lerp/overview
how does this help me?
we gave you several
you were doing wrong lerp before
cause i'm not using lerp.
i'm using movetowards.
this is the issue you have with your movetowards
well use lerp
It's a solution for interpolating between two points given time/duration rather than moving towards the value given speed etc
you said
rather than something like a lerp where it gets slower and slower.
this is wrong lerp
lerp stands for linear interpolation. it's linear if you use it correctly
also remember the values are constantly changing.
I'm not willing to write the code so you'll need to Google a bit or use one of the other mathematical solutions
yes, and you aren't accounting for that
the solutions we've cited do
don't use movetowards
yes but as i stated before Mathf.Abs(frequency - freq) / (SlideDuration / 100f); works fine i just don't know how to make the duration seconds rather than my arbitrary value.
is there any other way to prevent
No measure function set in this node's config
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
spam in 6000.2 besides restarting the editor? when i restart the editor, it goes away for about 5 minutes and then comes back.
speed = distance / desiredTime
the important thing is using the proper values in each iteration
for movetowards: don't recompute time, use new position
for lerp: use original position, remember elaspsed time
maybe stop claiming stuff works when it doesn't lol
it's arbitrary because your current usage of movetowards is effectively just wronglerp lmao
it does! why don't you think
var diff = Mathf.Abs(frequency - freq) / (SlideDuration / 60f);
frequency = Mathf.MoveTowards(frequency, frequencies[targetFreq], diff * Time.deltaTime);
Not certain but that seems to be a Unity Editor error and not something with some script that you've written. Try asking #💻┃unity-talk , sending bug report in the forums etc
it's not linear.
because you're using the updated value of frequency each time
yea, I made sure nothing in my scripts was causing it, I'll ask there thanks
@patent wedge you should stop assuming things you don't know
lerp and movetowards are the same math, both are linear if used properly
the problem is you aren't using them properly
like you said - keep in mind, the values are changing!
the important thing is using the proper values in each iteration
for movetowards: don't recompute time, use new position
for lerp: use original position, remember elaspsed time
you can use either lerp or movetowards here - again, it's the same math.
just make sure to update the variables that need updating, and don't update the ones that don't.
you don't seem to have a separate current vs target variable, so yeah movetowards would probably be more straightforward
but if you want it to be linear, you have to not recompute the speed every frame, because that would take the new distance and you end up with an exponential decay - the exact thing you were complaining about with (wrong)lerp
oh and yeah get rid of random coefficients you can't explain lol
Proper lerp and move-towards with linear non-changing speed.
Lerp:cs c = Lerp(a, b, t)where t would go from 0 to 1. Where t = 0 would have the value be a and t = 1 would have the value be b. t should not be some constant fraction in proper lerp.
Move Towards:cs a = MoveTowards(a, b, speed)where a would increment by an amount equal to speed till it's the value b.
hello, im planning to create a robot construction game where you build your own robot in a 2d grid and run the simulation to see how your robot behaves on its own, im planning to add a small code editor to add your own logic to your robot, does anyone have any suggestions on how i would structure the robot?
(pedantically - it would be MoveTowards(a, b, distance) or MoveTowards(a, b, speed * deltaTime))
I was going to use d for the distance to travel but I figured four single letter variables may be a bit much for some who are still learning.
So should I just do distance divided by duration? I really just want a simple clean way of doing this.
yes, that's what speed is
the issue before was that - again - you were recomputing it with the updated distance. you need to keep the same speed, calculated from the starting distance.
Meaning diff should only be evaluated once
Is it ok to put logic inside a class that is also a scriptable object?
I’ve asked this earlier but is there any projects I can look into to observe the framework and see if I’m doing anything wrong and improve
like the profiler
https://assetstore.unity.com/publishers/1
Grab one of unity's templates and dissect it
hey everyone, im trying to export my project to my friend who has mac, for some reason it wont open for him and displays a tab saying the application cannot open. anyone know a fix?
exporting the project how ?
trying to send it to my friend over dropbox using files
send what the project ? or the build ?
the build yeah sorry
are you exporting from a mac
no im exporting from windows
does windows support export single app file ?
anyway your friend can try seeing if its probably being blocked in the privacy setting.. since its from an unverified/unknown developer according to apple ..
when exporting i get the .app file and then contents and finally the rest of the stuff in it
for future this goes in #💻┃unity-talk. this is a coding channel
the folders are probably debugging files from build, it should only be that single .app you send
these are my settings and the inside of the contents folder which is in the .app folder
ohh I see.. windows shows it as folders directly..
guess apple couldnt be bothered to make it an blob
hmmm on here they are in a couple of folders deep
it is maybe that i compressed the folders and its something to do with permissions?
probably dropbox
is there any way to not compress the file and send it
put it inside another folder and zip that
another beginner question, if i have a player health that i want to be stored throughout scenes, where would i put that?
Does anyone know why my linearVelocity is Vector3.zero, I don't think I'm calling to it anywhere else
probably a singleton
Free tutorials, courses, and guided pathways for mastering real-time 3D development skills to make video games, VR, AR, and more.
is the rigidbody kinematic
It's not, but I think I might have found the issue
danggg.. cache your vars / components
so many repetitions can be avoided
Nevermind I didn't
not moving at all ?
No, the animator's float is changing as expected, but the linearVelocity is still Vector3.zero
is the animator taking over the transform maybe ?
What would that mean, and how could I tell
disable it / remove it, and comment out the animator lines
hmm good idea
isn't there smth about only one singleton?]
wdym ?
idk there's so much controversy about singletons, i thought i heard somewhere you should only have one singleton
nah you should use them without worry
just dont abuse / use them as crutch
would i also wanna use this for 'global' functions like, idk pause game?
yeah they generally used for that like GamePlayManager or something that controls flow of the game
- DDOL so they don't die between scenes
I closed my project and restarted it and it worked. But it was giving some animator error about an object not being set and Null Edges or something
I'll have to screenshot that next time, but also thanks!
Unity 2022 is riddled with bugs. The build window is incredibly slow, the MP4 player is incredibly slow, and this bug. 🙁
Could anyone help me with my (not at all beginner level) problem in Unity? It's about i's value in a for loop magically changing by black magic whilest trying to run a async method. The problem is rather complex so that's why I'm asking to ask XD
Example snappet:
for (int i = 0; i < operations.Count; i++)
{
var op = operations[i];
var localProgress = new Progress<float>(p =>
{
float groupProgress = (i + p) / operations.Count;
Debug.Log($"i: {i} | p: {p} | groupProgress: {groupProgress}");
progress.Report(groupProgress);
});
await op.ExecuteAsync(localProgress, token);
}
do this instead int index = i;
by the time that lambda run the i can be different
so capturing it like that should ensure its the value you expect it to be
var op = operations[i];
int index = i;
var localProgress = new Progress<float>(p =>
{
float groupProgress = (index + p) / operations.Count;
Debug.Log($"i: {index} | p: {p} | groupProgress: {groupProgress}");
progress.Report(groupProgress);
});```
why does it says Unity 2021.2.19f then ?
don't even think 2.0 was actual LTS / full release (I think it was tech stream?)
so riddled with bugs makes sense..its literally a preview release ?
what are you trying to do anyway?
Will give it a try, ty!
You have no way how much I love you
I went crazy for over 7 hours trying to fi this
No, that's another error, but in 2019, the path points to "2021.2.19f1-x86_64" when it should be "2021.2.19f1"
The slow interface bug is in the latest 2022 LTS version.
How can i make my class editable from inspector?
you'll have to show code, the question is too ambiguous
Guys, just one question, which is better for a fast paced FPS, charactercontroller or rigidbody?
kinematic
hey im debugging a little input system for the player and it shows this error on console, whats the issue and how do i fix it?
What does the error say
ill show you
Input code differs between the built-in Input Manager and the Input System, and changes are required.
thanks dude
whenever i create a new project it always starts witht his error message: CommandBuffer: built-in render texture type 3 not found while executing (SetRenderTarget depth buffer)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
dont crosspost
btw thanks nav i got it to work
i set it to use both input systems how come it says its recommended to not use both input systems?
I'm not sure why but I recall it warns you about mobile compatibility thing when you build to android
its pretty easy to use the new system, keep it on both then phase it out as you learn new one
ok thanks
Hey, I am using this singleton asset:
https://github.com/UnityCommunity/UnitySingleton
It's supposed to support editor scripts too, according to this:
https://github.com/UnityCommunity/UnitySingleton/issues/2
However, I keep getting spammed with the error seen in the picture.
I simply call the manager like this:
private static Transform Player => ColosseumSceneManager.Player.transform;
private void Update()
{
// Move camera to the player's position to allow for proper offset after rotation
transform.position = Player.position;
if (_rotateCamera) Rotate();
Offset();
}
Am I doing something wrong or is this a bug?
Please @ me and thanks in advance!
btw, I am using the latest Unity 6.3 alpha, that could be the cause.
line 29
Yeah, that's the best part, reported lines make no sense whatsoever :/
Could this be a bug?
I'll try deleting the library dir as I was doing some weird stuff just before this happened so maybe that corrupted or sm.
Why's the numbering here labled like that
What does that mean? Is the line above 29 here right before
yes, the line above 29 that says 1 is line 28
it shows the number of the line you are on and the others are relative to that
Here, I toggled it to make it easier for you.
Try commenting out 6, I'm just curious if it's complaining about that
or rather w/e 6 is here
like the 6th line in the colosseum scene manager?
What I'm eyeing from the error is 'instance field initializer' from the debug, but I'm not seeing a FindAnyObjectByType call
FindWithTag however is a similar Find operation
ah, that's from the singleton implementation I am using
btw, wasn't the library dir, I just rebuilt it and all the same sadly
I think this has something to do with how I am accessing stuff in the ctor but I honestly have no clue...
Like is this not a proper way to access a variable from a singleton?
[SerializeField, Required] private CameraManager _cameraManager;
public static CameraManager CameraManager => Instance._cameraManager ??=
Instance.gameObject.GetComponent<CameraManager>();
Oh wow...
It took ai pointing this out for me to notice o_0
See something weird about this line?
public static float DestructionVelocity = Instance._destructionVelocity;
Yeah, I used = instead of =>, which caused initialization and an error.
I genuinely don't know how I managed to miss this one, literally never happened before.
Thanks for trying to help!
hi i am new in unity and i am wondering if i have learnd java can i use it for unity?
ok thx
Technically you can if you're specifically writing native code for Android. But not in a way that matters for general game development
ok
do yall have som tips for what game i shud make?
Whatever you want. Start small though. Learn the engine before trying to make anything too big. Starting on a large project right off the bat is a recipe for frustration
😂
I'm thinking about a game where you spawn with a gun and speed run through it taking out all the NPCs
and low poly
3D?
yea
why?
Just wondering. Just looking at the trailer for Karlson making that game exactly will be tricky and take a lot of time. Just start small, work your way up from there. Start with just a player controller that you can move around and jump with, and add all the other stuff on top of that
yea
so when i am going to script the movment it just open note
Make sure you have Visual Studio (or Visual Studio Code) set as your external editor
Assuming you mean that when you double click a script in the asset browser it opens Notepad
oh ok
wehn i click on open
Yeah they do the same thing
Yeah. The Community edition's the one you want, that's the free version
ok
Hi, I'm experienced programmer but I'm new to the game dev and I'm shocked how different this is from actual programming.
I would like to talk about dependency injection / OOP.
I found that there is no such thing as a front controller in unity (same in godot and other engines except low level graphic APIs where I programmed everything myself).
Also there is no such thing as dependency injection.
No such thing as service container as well...
This makes OOP pretty much impossible in unity but I found 1 solution: lazy injection, which is passing dependencies after the class instance is created.
Problem: I want to use a component in all game objects but it looks unnecessary and memory consuming to call AddComponent every time I initialize game object. I don't need "unity-level" dependencies in my code... I need my dependencies in my code. Since there is no service container, I cannot get component from something global... instead unity prompts me to add component to the game object if I wanna use it. That's unacceptable.
Solution:
// THIS IS MY FRONT CONTROLLER, THE GAME STARTS ONLY FROM HERE
// ALL INITIALIZATIONS ARE PROGRAMMABLE (materials, game objects, components, call sequences), NO GUI IS NEEDED
public class Game : MonoBehaviour
{
void Awake()
{
var camera = new GameObject("Camera");
var unityCamera = camera.AddComponent<Camera>();
unityCamera.orthographic = true;
unityCamera.orthographicSize = Config.resolution.y / 2;
unityCamera.transform.position = new Vector3(0, 0, -1000);
camera.AddComponent<DragCamera>();
var mapEditor = new GameObject("MapEditor").AddComponent<MapEditor>();
// Init is my method for lazy injection of camera because I don't want to do mapEditor.AddComponent<Camera>();
// I don't even know if unity will create a new Camera instance or use the one from its internal instance contaienr initialized before Awake...
mapEditor.Init(unityCamera);
}
}
What do you think?
is the unity codeing c#?
I'm not super sophisticatedly oop-pilled but singleton patterns and potentially usage of [RuntimeInitializeOnLoad] as an initial entry point seems to solve a lot of my problems.
Not quite sure what you mean by
I want to use a component in all game objects but it looks unnecessary and memory consuming
I mean that I don't need to overhead my code with components if I can just pass their instances via Init methods.
How would you create singlefon of built-in Camera component and inject it in your classes?
I avoid singletons because they are anti pattern but I might do an exception for the game dev but only if there is not other choice. I found a solution already so I don't singletons but I want to hear opinion of game devs.
hah, it already broke everything it could
I'm after few months of low level API/shader programming
Why are you not using prefabs for this?
prefabs are static, I will use them once I need bigger not dynamically generated objects
If you fight the system, you mostly end up with a struggle in trying to still use unity properly. You also lose out a lot on the actual benefits like configuring stuff in editor rather than through code. You'll find a ton more people here that dont bother with proper DI and instead just stick with a singleton where needed.
It also does sound questionable why your camera would ever be a singleton
Even from your example here, its clearly an "everything defined in code" route which just wont benefit you at all. This also is very bad for designers or any non-coders in a team who would need to configure something and would usually do so on an existing component/prefab
yeah camera as a singleton was just a stupid example
I need proper OOP because it makes my life a lot easier and makes me do things because I like it (and I hate game engines in general)
yes exactly, "everything defined in code" is the way I want to go and I believe I can achieve everything with it just as you with GUI
I believe it's a matter of preference because I'm completely alone (no team) and it won't change. I will never call myself a game dev so I don't need to follow guidelines
Then use proper OOP however you like and treat unity simply as a way to render objects. Nothings stopping you from doing this and coding it exactly as you would outside unity
Ive only seen 2 people in this server defend this kind of style and I know one quit like 2 months in.
Again you can fight the system, but don't blame the system when you struggle to do basic things down the line
You might be more comfortable with Monogame for example which is still C# but unopinionated. You're not going to have a good time with Unity if your preferences clash with how it's designed to be used
I want to give it a try at least 🙂 let's call it a challenge
I decided to use unity because godot is very poor if it comes to 3D, shadows and performance (I tested it, it's my opinion). Unreal is too much for me...
Its less of a challenge and more of stubbornness. Theres nothing about this thats a challenge. Youre simply just setting yourself up to configure things in a worse way that isnt sustainable, especially for non tech people. That's all
All the power to you if you wanna write it that way. Your game will function the exact same as someone who doesnt write it that way. Will it get produced faster/have more players? No
and I believe I can achieve everything with it just as you with GUI
Honestly nah
Like in a literal sense yes
in a practical sense nah
especially for 3d
Theres a lot that instantly break the workflow too, like the fact unity already has a lot of components with values you arent going to be setting in code
"everything" is a big word, it's obvious I won't do literally everything is code
Even the amount that youre thinking of doing is still the same issues
No one's physically restraining you from doing it, but trust me you're going to be questioned by almost everyone who helps in this server for doing it in a non unity way
I copy their default values in code by creating them manually first and test them. Also I learn them with AI and tutorials to maximize the control I have over all components.
ai is shit for unity and most things
your going to struggle a lot here
if your fine doing so by all means
by design this is just a bad way of using the engine
well AI is horrible but much faster than learning the doc, it speeds up self-learning a lot
Idk if that 2nd sentence was meant to instill hope but it definitely makes me think you're hitting a brick wall faster than you realize.
This sounds like an abysmal way to code
nah
But 🤷♂️ call it preference if you want. I dont think I can give anymore big red flags than I have already
the only real problem I see is that my project won't be maintainable by anyone except me (and it's good, I'm really doing it just for fun)
"Except me" wont be the same you in 6 months. The same reason people comment their code if they're the only one using it
anyway thanks, I just wanted to know if there are any real blockers
practicality
How do you fix the problem in a 2d platformer, that when you are falling and just holding D into a wall and you just dont fall as long as you hold D (or the Key for moving in a direct)
any1 know how I can change this value via code in hdrp: the temperature.
Hi guys is it possible to get the volume level of audiosource while playing using update()? Completely slience = 0.00f, loudest = 1.00f
There are a few DI frameworks made specially for unity and you can create classes that arent components. Static classes exist
Thank you worked perfectly
nvm, i just made it [System.Serializeable]
Yep take this: https://docs.unity3d.com/ScriptReference/AudioSource-timeSamples.html
And then find the sample in the audio data: https://docs.unity3d.com/ScriptReference/AudioClip.GetData.html
I am very confused. I have a few Item prefabs for my game and i have the unity version control enabled. For some reason, everytime i change something on 3 specific items, almost every time i launch the game in unity the prefabs reset back to what they were before. Even completely creating them anew doesnt help but its only with those specific 3 and i dont understand why
They also dont get automatically checked out if i change anything
but even manually checking them out doesnt change it
Could anyone help/explain why this is happening?
update i disconnected it from version control to see if its that but nope
Hi, I'm trying to write some tests for my code, but the editor doesn't seem to be able to create any test scripts anywhere, I always get the invalid path error.
I feel like I'm following the documentation, I create the test assembly director, but then when I go into the test runner and click create test script I always get an error
Show the error message
I'm trying to do a perspective change from front facing to back facing when the player enter this collider, how do I make it so it transition smoothly instead of instantaneous
hello guys, Why can't I find the playerprefs database in my browser (Chrome)? I know they work because I output their data to the console, but I can't find them in IndexedDB?
typically i see people just use 2 seperate cams..
when u enable 1 disable the other it'll automatically do a transition (w/e set up on the brain)
ie. you could have 1 cam w/ a certain followTarget
you could have a 2nd cam w/ a different followTarget and just swap between the 2 cams instead of chnging out the followTarget
oh you're right, thanks
im trying to invert the movement by multiplying by -1 if it's enter the collider, it worked but how do I time it so it doesn't invert instantaneously
Well currently does the inverting of input cause the player to leave very soon after entering this area?
Perhaps yea when they exit the trigger it can be a delayed change (which you would want to cancel if they re enter the trigger again)
you could use a coroutine or async method to do this
what's that? sorry I'm still a beginner so I have no idea..
Id recommend a coroutine then, its a method that you can invoke and it can wait some time before doing something:
https://docs.unity3d.com/Manual/Coroutines.html
private void IEnumerator SetInvertAfterDelay(Player player, float invert)
{
yield return new WaitForSeconds(0.5f);
if(player != null)
{
player.invert = invert;
}
}
start with: StartCoroutine(SetInvertAfterDelay(player, 1f))
thank you so muchh
make sure to "cancel" the coroutine if the player re enters the trigger. the doc page i linked hopefully covers how to do that
do you use blend tree?
no
Does the "forward" dir of this object match the visuals of the object?
forward being Z+
Never mind I think I am doing it wrong did a bit of researching and I should rotate the rigidbody with moveRotation instead of changing its transform
So the issue was that it instantly changed? You didnt add anything to do that so what did you expect???
You can use Rotate towards to rotate over time to some target rotation easily (as you can call this every frame with your current "target rotation")
no the issue was the player wasn't rotating it the movement of direction. now I am looking at unity discussions and I should rotate it with moveRotation instead
I think you got lost during your search
Rigidbody.MoveRotation() is to change rotation using the rigidbody interpolation to help but this on its own wont fix the issue if your models "forward" does not match the visuals.
this isnt really about code but:
why is there not a color option in the camera inspector?
but setting transform.forward as you were can work as long as the direction is world space
the clear mode has to be changed to solid colour for it to appear
ty it was under environment --> background type
well thats different
the scene BG and camera clear are related but not the same thing
anyway ask elsewhere in future
where?
ok thx
Thanks I fixed it. Also is this how you correctly rotate using moveRotation?
Looks fine to me but I didn't really help did I 🫠
looks good.. i like the 8-D movement
how would I make the turning more smooth? should I use vector3.lerp?
or quanternion slerp/
What about what I mentioned above
what did you say?
#💻┃code-beginner message
Rotate towards is the way to go
Like this?
Yes. You can do degrees/Time.fixedDeltaTime to make it be degrees per second.
But should be working already
hey, what would be the easiest way to make a countdown for a stamina bar, or a hunger bar for example?
countdown? You mean a timer? Just a float and Time.deltaTime
it depends what part you mean exactly
the UI bit?
The actual timer logic?
no ui isnt important rn its more of a hidden countdown for hunger etc which gradually gets smaller, depending what you do. so ill just subtract a multiplicator * time.deltaTime from my hunger efloat?
It really depends
you said "depending what you do"
so sounds like you'd subtract from it in response to some actions by the player
for example faster movement would use up more hunger
it also depends on if these things are "continuous" actions ( like running) or one-off actions (like swinging an axe)
but it's really not complicated
stamina -= staminaCost; for one-offs
stamina -= staminaCostPerSecond * Time.deltaTime; for continuous actions
its for little npc characters having random stats so some move faster then others etc. there arent really one-offs and i dont plan on implementing those
I use Vector3.Slerp for a character that requires smooth rotation when moving, lerp would do the same thing as in the video.
already fixed it!
ohh great
I'm not sure why but my player keeps floating upwards every time I press play and begin to rotate or go forward. Is there something wrong with my code?
or for a stamina/health setup theres a combo of the two
private void HandleHungerTick()
{
tickTimer += Time.deltaTime;
if (tickTimer >= tickInterval)
{
hunger -= hungerCostPerTick;
tickTimer = 0f;
}
}```
like for example every 2 seconds it takes 5 from hunger
this means u have to go the full 2 seconds for a deduction to happen
transform.Translate is based on your object's rotation
basically this will go forward in relation to where your object is facing. Which will start to be upwards as you rotate
find it a cool mechanic from time to time.. (i like my status bars to have chunks to em)
Thank you for the help! I'll troubleshoot from here. 🙌
How can I make my player move freely while in the air? I basically change the movement speed when in the air is that a no go?
I mean looks like it already can based on this
yes just a bit but I want to move a bit more
then add more force
looks like you're doing a force-based or momentum based system
if you want faster acceleration you need more force
based on the simple F = ma equation
what do yall think is 2d or 3d who is the most easy for a now dev
Alternatively you could switch away from a strictly physical force-based system and set the velocity more directly
It really doesn't matter all that much
ok
There are specific 3D game types that might be more complex - usually if you have complex 3D rotation involved like a spacship-flying game
but for most types of games, FPS or TPS for example, there aren't complex 3D rotations involved.
start however you like
ok
and there are complex 2d things too!
2d vs 3d aren't harder or easier than each other - just different
i am thinking abut 3d
ok
while in the air? this is what ive got : https://paste.ofcode.org/AU7ZBgxM4DZTLb8D8kN9kK
Frankly your code is very simple, which leads to simplistic behavior.
If you want to do something very specific like "if I'm in the air and the player pushes their joystick in the opposite direction they're moving, I want them to be able to very quickly change directions" then you will have to write the code for that
e.g. psuedocode:
if (!grounded && horizontalInputDirection != currentHorizontalMovementDirection) {
// do something special, either adding more force or instantly setting the velocity the other way, whatever you want
}```
this is the error i get
void Update()
{
CalculateHunger();
}
private void CalculateHunger()
{
currentHunger -= speed * 0.1f * Time.deltaTime;
if(currentHunger < hungerThreshold)
{
LookForFood();
}
if(currentHunger <= 0)
{
Die();
}
print(currentHunger);
}```
this code should count down to zero but it always stays at its default value whic is set before. can someone tell me why this happens?
what is the value of speed and have you debugged that the code is running
oh
havent actually asigned a value to speed this might be an issue 😅
seems like it , anything * 0 is 0 🙂
Hey everyone, could someone explain to how Resident Evil's signature movement works but in Dev terms?
what is " Resident Evil's signature movement"
I'm trying to recreate that slow, realistic movement but I don't know how I should go about it :/
resident evil changed movement through the years
are you talking about tank controls ?
The movement from Resident Evil Biohazard and Village, sorry I should've explained it better in the original message
thats not "signature" movement , those are more contemporary movements
so like FPS movement you probably want to look into whatever first person tutorials cover this topic
what makes those really stand out is the good animations, like any other FPV game
I mean making an FPS movement controller is just as simple as that, but getting that realistic feel is a different thing (Mainly talking about Camera and Perspective)
So if I'm thinking correctly, they use something along the lines of a physics based camera? (Sorry I'm not that good with terms)
not sure what you mean, what makes you think camera is physics based?
Please bear with me, I'll try my best to explain.
So basically I'm saying that the camera moves with the player in a way that it would simulate real walking?
mhm thats just animations selling the look, otherwise its pretty generic
things like swaying / bobbing are the terms you want to look into
So to start, would you suggest I build the perfect player movement (To my taste) and then let Animations do the rest?
pretty much
Yes that! I was scared of using those 2 words because I thought they were wrong and would make me look stupid but yes, that's exactly what I was looking for!
some games move the actual props you're holding, some sway the camera (some do both)
No one should want to perfect anything to start with though, systems like this are pretty iterative and a implementation in a game like RE is going to have a ton of time, experience and testing involved to make it that good, so don’t be too surprised if you end up short of that
at the end of the day they have dozens of animators that know what they're doing to sell the realism . Strictly talking about the movement mechanics, they are pretty generic
An example question: If IK is used (Imagine the player is a spider for simplicity). The camera would move alongside the rest of the bones, right? Which would simulate close to realistic perception?
Could be wrong but probably not tbh, that doesn’t sound like enough consistent control
Things like rough surfaces would move the camera differently and so on. Purely because of how the physics are working on it
I'm not an animator so I can't say for certain but you can get some decent results already just by parenting camera to moving bone but it might not be the control you're looking for
Think of it like a gizmo perhaps? Don't know exactly how to explain it
The camera doesn’t have to be realistic, it has to feel realistic
Okay that's a really great point
But yeah, so if I understand this correctly, I should focus on Swaying and Bobbing to get that slight realistic effect?
I mean to start it'll be simple, slowly changing to the style of the game
Sounds like a good route to down yeah. If your really serious about this might be worth looking for any available gdc-esque talks on this kind of thing or even finding similar games that have view bobbing or other relevant settings available so you can compare the difference
Hi
I'm sure there has to be alot of documentation on this style of realistic movement, correct?
a little bit of sway goes a long away to make it feel less "stiff"
I would hope so but it can get dumb when your looking for actual industry discussion and resources, you can probably find good stuff
I'm actually trying to make a survival horror game (Of course not as good as Resident Evil but I'll try). So yeah, I LOVE the new Resident Evil movement style, I'm stealing taking inspiration from it
not a bad idea, the new Resident Evil def breathe new life into the game . Def brought the franchise back
That but with a slowly sway speed (Maybe different bobbing values) would look amazing!
I also did find a FirstPersonMovement asset but then again, it only had bobbing and no sway, so it looked Stiff until I slowly changed around the X and Y values for camera bob
It got really close to what I was looking for at the moment but I'll be making my system instead
yup exactly, like everything else it needs to be "tuned to taste" so keep iterating eventually you will get the look you want
Thank you for helping! I'll get right to it
If this fails I can always go to a complete Resident Evil 5 style 😴
Help, I've been trying to create play mode tests for a week and i can't seem to understand why i can't do it
play mode tests ?
for the code
you mean like Unit test?
I know what unit tests are just didn't know the name " playmode tests" was a thing. maybe if you show the setup and explain a bit someone whats not working , someone might be able to chime in
Thanks, well
All i'm doing is I'm following the documentation on how to create tests and test assemblies
alright, you need to give more info if someone is to attempt at all to help debug this
we are not mind readers
I have my scripts i want to test in a folder, then i created a test assembly folder through the asset section, then I told the created assembly file to reference the one in the script's folder, and finally i try to create a test script by selecting the test assembly file and using the test runner feature "create new test script" but I only get the "invalid generated unique path" error
can you show the error and full stack for it
Generally, for a turn based card game, should I use coroutines for things like turns and playing a card?
I'm not really getting into the specifics yet, only a general framework I should follow before I implement anything
I feel like main game logic can stay in the update function
which version of unity are you using ?
coroutines seem like they would be useful for time sensitive things such as animations and effects
6.1
up to you . coroutines can offer a good way to control the flow of time / events if needed
I'm also coding this to be multiplayer(internet stuff), could I build a turn-based framework and then build the multiplayer on top of that or would that cause a mess?
are you able to try unity 6.0 . just curious if this is some type of bug , i seen this error before
You should usually make a networkgame with networking in mind during the structure, much more difficult to add the networking parts later on
how can i downgrade
got it, well if that's the case I've already finished the non-networking parts(deck building), I guess I should add in the networking part now?
dont. just install 6.0 aside
and try making the same code/ project
if its still bust its probably you did something wrong at some point
How do I code with networking in mind? Is it like telling the game manager that there'll be a player 1 and player 2 but player 2 is a try/catch check for internet connection/lobby system?
why does it ask me to make that field static ? 🤔
you cannot access a non-static member in a static method (without an object reference)
use the singleton for the manager
thats the whole point why Networkmanager has a singleton
its even in the documentation
wait wrong link
holy shit the new docs , are the old docs ...
https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@2.5/manual/tutorials/get-started-with-ngo.html#the-helloworldmanagercs-script I'm following the official Unity documentation, so it has an error ? 🤔
I have no fucking idea why they changed that...or the docs..
I feel like unity has a habit of doing that
it literally was just NetworkManager.Singleton.StartServer() etc.
Well just under it they have the same snippet of code but with singleton 🤔
I feel like thats cause they are not consistent on which employee work on it and it all gets lost in translation
exactly my point
Theres so much more to it than that unfortunately, it’s a whole different mindset of composing code
they changed the docs in such a haste they fucked everything up
where can we report that please ?
at the bottom
all the legacy links I had for Netcode docs now link to the package docs 🙄
okay but where do I start? Do I just read the unity manual and try to set up a dummy networking thing? And then after that have a wait until player A does a legal action and reflect over to the other player's monitor?
The NetworkManager is a required Netcode for GameObjects component that has all of your project's netcode-related settings. Think of it as the central netcode hub for your netcode-enabled project.
the old docs for netcode was better imo but alas we're back to the shit Docs unity has now for packages
Following the manual and doing super simple testing with just text is probably a good start
so the link nav just posted?
they mean just in general . Like the docs does have example on Ping message Pong back (RPC) example
knowing when to use NetworkVariable vs RPCs
shit like that is more important
Still can’t get over NetworkVariable OnValueChanged not firing when it syncs a pre-existing value
how do you mean?
like initializing it ?
If a client joins a pre-existing session when they get the networkvariable values that doesn’t invoke the event on them
only if the value changes while they are in the session
iirc on in networkspawn you usually want to do something like
MyValueChangedMethod(old , myNetval.value)
that tells connected client to sync the value
That’s a way to get around it but feels super jank and inconsistent
Makes getting comfortable with ngo a pain imo
yeah that to me was a bit confusing for me as well
until i had to work with RPC params :X
the old method was easier than new one 
Apparently IsOwner not being set yet in behaviours when OnNetworkSpawn spawn is run too feels hmm
still , NetworkVariable still feel like cheating..
its almost too easy lol such things would be so difficult just dealing with just RPCs
I'm missing something obvious but not sure what. I have a BurnEffect object that inherits from a EffectObject object. The BurnEffect has a IEnumerator Coroutine. Can I make that coroutine accessible through EffectObject?
accessible in what way? they are just methods, I don't see why not
as long as they are started on a MB
when I try to check effect.EffectCoroutine, where effect is an EffectObject, it says EffectObject does not contain a definition for the coroutine
if you want it on the parent EffectObject, shouldnt that be the one with coroutine instead of BurnEffect , or am I missing something.
the different effects like BurnEffect, SlowEffect, etc all inherit from the EffectObject, but the coroutines are different, and not all of them have one
so I wanted to check if that Object has a coroutine and start it if yes
hmm I suppose you need to give yourself some way to know it does
like a boolean or a more clever way

