#💻┃code-beginner
1 messages · Page 647 of 1
I see
thx for this btw i'll consider using any third-party tool to try detecting the causing of this issue
What third party tool?
There's nothing to detect here.
Just close programs that you don't actively use, shut down processes, google guides on minimizing windows memory usage, on how to disable edge processes, etc...
As for disk usage, you can see that in task manager as well. Just sort by the "disk" column.
if only there was some kind of manager that displays all the running tasks... which you had shown above.
Downloading more stuff isnt gonna free up memory
thank you, i never put much thought into any of these before i'll consider doing this asap
task manager already do that, i'll try to detect any unnecessary software that is running in the background
might even able switching to VS code by then
btw going back to this one no the script isn't attached perhaps it could be what's causing the error
ye it needs to be somewhere in the scene on an active gameobject
guys i just started using unity and i followed a tutorial but the code they gave isn't working can someone help (its classic movement code ig in first person view)
yeah thx for the advice, i should've put it on the gameobject that i'm hitting
btw may i ask how did you figure it out that easily? so in the future when i encounter it next time i could tell what's causing that problem
Start with identifying the issue:
- are there errors?
- does the code execute?
- does it execute as you expect?
Etc...
well how do i find errors lol
i recommend you not to take any random tutorial, start with unity essentials instead
i actually cant add the script rn
I'd suggest with going over unity basics either in the manual or unity !learn:
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
btw @rapid thunder unity essentials is a free course made by unity itself (it's an excellent starting point)
Definitely the latest version of unity Unity 6
- understand what the error means. In your case it's null reference, meaning that the find method that you used, returned null.
- check your setup according to the error. In your case, that means researching how the find function works and when and how it returns the correct reference. Spoiler: it only returns a reference to actual instances of your class in the scene or loaded assets.
and 1 last question i know myself im not a coding guy if i need any help of coding something different can chatgpt do that? (dont have a friend who is coding too btw dont judge using ai please im just a guy who wants to learn) lol
i utterly can't stress it enough, if you're starting out to learn programming don't use ai at all (maybe there are exceptions but if you do want to learn it seriously then no don't use ai) besides
what i recommend you to do instead
It might, but you shouldn't rely on it. Without knowing what the code does, you wouldn't be able to solve issues that chat gpt can't (which is the majority of issues).
don't start to learn programming in unity that would be messed up, instead take a programming (CS50x is a great choice they have their own server on discord and offer a much better ai) after that you could go to learn unity/C#
@rapid thunder
True ai is a lil bit of trash in coding even i (i'm still a beginner in programming) did notice that
Thx man, one more question does this knowledge comes up with experience in unity or is it related to my problem solving skills / programming skills (of which i'll try to work harder on it) ?
It mostly comes with experience. The earlier you get the mindset of investigating everything thoroughly, the faster you will improve.
really appreciate it! that information would come in handy!
i cant even enter the learn page lol
Using VPN perhaps?
it works totally fine for me check your browser
https://learn.unity.com/pathway/unity-essentials
Free tutorials, courses, and guided pathways for mastering real-time 3D development skills to make video games, VR, AR, and more.
youtube videos working fine but their own videos are not working at all in chrome
nope i tried with vpn and without vpn didn't work
cant open the first one but i can open the second youtube video
for videos on unity page you have to activate settings in the cookies / advertising tab there...
dont know where you can find it .. but when you have the tab/popup on the bottom click on the settings part...
i cant find this place...
i just went to the https://assetstore.unity.com/ page...
i dont think its working...
i cant watch it on microsoft edge chrome and opera all 3 of them
hey guys im trying to make a shape change color once it gets hit twice, does anyone have a tutorial for that?
ah i found it.. when you dont have the bottom popup theres a icon on the right bottom...
so far i know for videos to work you need the functional cookies active..
Which part do you not know how to do - the collision detection or the color changing
functional cookies are active but that is on asset store not in unity learn page
i think the collision
i have it so once it gets hit it changes green
but i want the condition to be that it changes green only when its been hit twice
So, instead of changing it to green, add one to a variable
and if that variable is two, then change it
ohh good idea
should work for the whole .unity domain
hi, could anyone help me how to make a active ragdoll? i've tried making it with IK (two characters, one physical, other one animated) and it always resulted to the physics engine just exploding. i would be grateful for any tips
Might be better off asking in #🏃┃animation
ok, thanks
My Friends would like to test out what I have so far, how do I send them a Build for them to try out?
- not a code question
- build the game and give them the resulting build files
see #854851968446365696 for what to include when asking for help
#archived-shaders tis the place probably. Colour tinting will affect the whole model on default shaders.
found the solution so if that happens "explaining so you can explain to others btw" when it happens you have to download "Allow Control allow origin" from web store then activate it and reload the page then its working fine
why is the book not falling even though i add rigid body to it?
When I place a tower I can no longer place another one on top because it registers as an occupied position. But when I am adding all the objects in the game to the occupied position so that I can't build on top of them I can still build on top of those objects. (It is detections 309 objects)
#💻┃unity-talk
anyway..the book gameobject is Marked as Static hence why it wont move.
not in 100 years would i have looked at that checkmark lol
yeah took me a few takes to see it, its not normal you add physics to something static lol
i see thank you\
good catch nav eagle eyes
mass of 10 for a book seems a lot lol. 20lbs book
Btw mass doesn't affect falling speed, idk if thats what you were trying to do..
how can I make it so that any button click in the game plays a click sfx?
which buttons?
buttons is vague term
UI button
Link an AudioSource with the OnClick or use code
right, but doesn't this mean I have to do this for every single button?
most likely yea, but there are many ways you can automate it if you really want to 10x your code
what if I have a script that find all buttons in the scene and adds a listener that plays the audio source 🤔
sure you can do that
just use a singleton with one audiosource and a bunch of Audioclips, (maybe a list of audioclips)
maybe do
void OnEnable(){
for (int i = 0; i < myButtons.Length; i++)
{
myButtons[i].onClick.AddListener(PlaySoundMethod);
}
}
private void PlaySoundMethod(){
SoundManager.Instance.PlayMySound();
}```
straight forward
you could also register a static event probably
For unity how do 2d character models work?
Can I just import them from my iPad on my computer
that's a pretty broad question
what files do you have?
Can anyone reccomend a good tool for planning code flow and/or data relationship diagrams as flowcharts? MSWord's tools are fighting me to the point I'm considering thumbtacks, string, and a corkboard as an alternative
You see, I’m not sure
Right now it’s a blank project that I’m trying to get started
I mainly wanna know if I can just import images of the characters on to my computer then just use those images on unity
if they're supported formats then yes
Guys i need some help, i'm gonna go crazy.
So i have a list for a float, i have 2 element on my list, no more no less. What i want to do is add 5 to the first element so i do "itemTotal[0] = 5;" Which work cause it the first element in the list, then i wana try with the second one to make it equal to 3 so i do "ItemTotal[1] = 3;" And it tell me it's out of range, EVEN THO BOTH OF THEM ARE INITIALIZED, WHAT'S WRONG
have you actually confirmed that the list has a length of 2?
yes
how
and for some reason when i do it unity decide that why not delete it
in the inspector there is 2
show the inspector and the code
No forget about it i'm the bigest dumbass ever
XDDDD
so i'm gonna explain what wrong
i have a foreach loop and the problem is i was asking to apply the value to the other one before they were even initialized
i wana die ;w;
" the value to the other one before they were even initialized" ? huh
Don't worry about my english right now it's been 3 day i didn't sleep
i'm kinda dying right now
but coffee help a tone
sleep will help a lot more
Hi! I was looking to follow unities https://learn.unity.com/project/prototyping-a-procedural-animated-boss?utm_source=YouTube&utm_medium=social&utm_campaign=evangelism_global_generalpromo_2021-02-17_prototype-series-procedural-walker-learn but the file link is broken.
I tried doing some of it on my own but I'm unsure how to get the cinemachine dolly to work.
Is there a location I can contact a mod/admin to get the link fixed, or possibly get some advice on how to go about handling the cinemachine? atm, it seems to cause my rig to split a little unnaturally
I have this issue where when you move in a direction and jump and you let go of wasd the player will immedietly stop moving which I dont want . What I want is when I jump and move forward and let go the player will move in that direction. I'm very confused on how to implement it.
what you describe is called momentum
you need some deceleration logic coded in manually
you're immediately stopping velocity by setting it to 0 right away without inputs
the same way you make "gravityVel" you need also motion velocity you track, slow / speed up
Is there a way to "select" several gameobjects, store them inside a list and retain the ability to adjust them directly?
I mean like being able to loop through that list and disabling each one, etc.
I tried creating a public list, dragging the gameobjects from inspector into there, but it seems that doesn't work for what I'm trying to do
why not?
Seems they no longer reference the actual gameobject in the scene
I don't know whetever I have to instantiate them through the script in order to do stuff with them
are you trying to put scene objects in a prefab?
I'm confused why I get all these errors after I save my files while the game is running?
The gameobjects are prefabs themselves
that doesn't clarify whats going on lol
Prefabs into SceneComponents works fine
the opposite doesn't
maybe make a video of issue?
Like so, and I want to control how many of these fish objects are activated at a given time
yes loop and array/list is the way to go
when you find yourself numbering variables like this is best to always use a collection
Yes I tried just having a public GameObject[] and looping through that but seems it didn't work
yes but we're back where we started..
in what way doesn't work ?
it should work fine
- how are you sure the function is running
- are you checking the correct objects
Fok I should get some sleep, my thing was just disabled 😭
Must have hit it by accident
Oh actually not
It was being automatically disabled every time I hit play
that means you might have a Null Ref in Awake
Yes I figured, I put everything to Start and it works for now
bump
A null reference exception means something on that line is null, but you're trynig to do something to it anyway. Look at those lines, look for anything before a . or a [ and see if its null
my issue is it's weird though because it works when I run it normally but if I save my code and rerun while it's running
that's when the issue happens
wym isn't that a normal feature?
Absolutely not
oh
It's never worked
No. It needs to recompile
They've tried to add options for it and it sometimes works but only if you're changing POCO objects that don't touch any Unity code
but if you do anything that's a behavior or scriptable object the entire thing just instantly dies
okay appreciate it thank you everyone
also does LayerMask.GetMask() do a OR or an AND of the layers inside of it
LayerMask.GetMask(ScStrings.GROUND, ScStrings.RAIL, ScStrings.WALL) I want this to mean that if it's a GROUND or RAIL or WALL
but i'm not sur
sure
why not just use a LayerMask variable ?
do you want multiple layers in one variable?
yeah I want an OR of them
yes so use a serializedLayerMask then assign the values in the inspector
its a bit more modular than fixed strings
Show the inspector for the bullet
oh okay
btw i changed speed to 10 and it doesnt work
Did you change it on the prefab
This says otherwise
This is an instance of the prefab
oh shitto i forgot
and i noticed smth strange i go backwards
when i increased the bullet speed
and u right i changed it and the only problem it falls
and not go forward at all
Seems like your bullet is facing down then
Select whichever object has the gunScript on it and show the transform arrows in the scene
so, the blue arrow is the direction your bullet will be facing
Is that what you want
btw i changed script to transform.translate(vector3.forward * time.deltatime * Speed); and it goes to the left
nope
u smart tbh
and u right as always stupid me thanks brother
i will basically change the forward thing
Why is that commented out line the angular velocity
That would be why it's not working
i removed it btw
i used linearvelocity too
If you have a rigidbody you should use it
i will thanks smart boi :>
hmm it still falls
though i changed it from forward to left to make it go -1,0,0
Hey yall, have a bit of a weird situation with my first person camera rotation - the camera rotates faster while the player is moving, and there's some weird quirks with the camera rotation in general, doesn't behave naturally and jumps ahead at times
player is controlled using rigidbody, interpolation is on - turning off interpolation helps with the camera rotation speed, however the camera still jumps ahead
using UnityEngine;
public class PlayerCamera : MonoBehaviour
{
public Transform cameraHolder;
public Rigidbody playerRb;
public float sensitivity = 5f;
private float xRotation;
private float mouseX;
private float mouseY;
private void Update()
{
mouseX = Input.GetAxis("Mouse X") * sensitivity;
mouseY = Input.GetAxis("Mouse Y") * sensitivity;
}
private void FixedUpdate()
{
// Rotate the camera holder (vertical rotation - pitch)
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
cameraHolder.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
// Rotate the player body (horizontal rotation - yaw)
playerRb.MoveRotation(playerRb.rotation * Quaternion.Euler(0f, mouseX, 0f));
}
}
might've gotten my issue solved too with the following
public class PlayerCamera : MonoBehaviour
{
public Transform cameraHolder;
public Rigidbody playerRb;
public float sensitivity = 5f;
private float xRotation;
private float yRotation;
private float mouseX;
private float mouseY;
private void Update()
{
mouseX = Input.GetAxis("Mouse X") * sensitivity;
mouseY = Input.GetAxis("Mouse Y") * sensitivity;
// Rotate the camera holder (vertical rotation - pitch)
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
cameraHolder.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
// Rotate the player body (horizontal rotation - yaw)
yRotation += mouseX;
playerRb.rotation = Quaternion.Euler(0f, yRotation, 0f);
}
}
this is bad.
move rigidbody in FixedUpdate. Remove time.deltaTime.
why is transform translating setting itself to rb.vel ?
Don't use transform-based movement on an object with a rigidbody
oh yeah that's a huge mistake, it causes so many issues
rigidbodies aren't meant to be transformed or translated
especially if you have interpolation on in them
surre
oh thanks
didnt see the chat for sometime mb
but i dont know what to do espically now the problem is back
it falls down even when i change up to left or to anything
show current !code, use the link 👇 copy and paste link with the class
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
here
why didnt you implement the other fixes?
didnt see that
also show origin of the bullet
idk how basically
and dont ss code
if youre using a rigibody why dont apply force in the gun script
didnt think about it cuz im newbie
thanks
wdym how ? there wasnt anything different to what was said
that thing is confusing my small brain
i did what she or he told me to make it prefab
and to change the transform.translate to rb.linearvelocity
if you don't understand how to make code blocks in discord then you can use one of those links and post code in there instead
what prefab.. Im talking about this #💻┃code-beginner message
ohhhhh stupid me saw only this is bad
but also you have the show the prefab origin for the bullet and the firepoint
no use links
thanks
codeblocks are meant for small code
his looked small enough, though yeah it's probably easier to just use the links
an entire class i not small code lol
what to do to continue
A tool for sharing your source code with the world!
im stupid u forgot ??
making a game is more complex then copy and pasting
ik lol
Can I make all those default values of the Selectable that I am not using not show in inspector? Cause they seem quite hard to find on the Selectable Interface
just a quick question, have you went through the unity learn stuff
so you should probably learn the basics before rushing making a game ?
@wraith shuttle
yeah finished the car and roll the ball
i did
finish all of it
clearly wasnt enough..
it's hard to believe that you went through everything if you don't know about sending links
no meme reactions #📖┃code-of-conduct
anyway show the required stuff. and make a thread so you don't flood other peoples questions
basically i want it to move forward
simple as that
brother make a thread
what was hard about changing
rb.linearVelocity = Vector3.left * Speed * Time.deltaTime;
to
rb.linearVelocity = Vector3.left * Speed;
and also that direction looks sus.. why is it left. You have to show all the pivots
again in a thread..
lemme fix that put it in fixed update
i was trying all basically
that wont fix falling directly but other issues later on / change of fps
yep
i wanted to make sure that it isnot that
i changed it later to forward
and now it works thanks
if you come back when it's not working again then please make a thread
confusing ik
sure and thanks i was being stupid idk why probally cuz tired
don't see how that fixed falling
btw deltaTime was reason it was slow unless speed around this high Speed = 100f
i removed deltatime and it worked
very skeptical
Maybe you should try to code it by contacting the live ssupport
Because they are live in everything the do
what?
what?
what?
is that a bot? super sus username
probably
Hahaha so funny
spambot going haywire
ehh i was wrong i didnt finish all the unity pathway
<@&502884371011731486> i think we got a spambot, seeing weird stuff from the python server as well, looking at their messages there
don't double ping
i hate myself cyaaaa
thats pretty evident...
i finished like half or smth like that
didnt do the sound effect , etc ...
@tawny ermine There is no off topic here. If you're not contributing to the conversation, please don't post.
the point is to do more basic project than what you're doing now so you can grasp the engine first and code, otherwise you just struggle jumping from problem to problem with no plan
finish the essentials and the junior programmer courses
cameraObject = Camera.main.transform; is null, it shouldn't be. I am following a tutorial and so far the camera is null for some reason.
Show the inspector of your main camera
Are you getting an error? Or is the code just not doing what you expect?
PlayerLocomotion.HandleMovement () (at Assets/Scripts/PlayerLocomotion.cs:29)
PlayerLocomotion.HandleAllMovement () (at Assets/Scripts/PlayerLocomotion.cs:23)
PlayerManager.FixedUpdate () (at Assets/Scripts/PlayerManager.cs:22)```
when i start the game, this spams my console
Check if the character has everything assigned to it
No you don't need to put the camera there
show the playerlocomotion script in full
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Might want to re-run the project and get the updated line number
it still says 29 what?
hmmm so the cameraObject = Camera.main.transform; line could be the problem, because i don't think that's how you get the transform of the camera
i believe what's happening there is that you're trying to get the transform of the camera class itself?
Clear the console, save the script, re-run it
ook it says 30 now
moveDirection = cameraObject.forward * inputManager.verticalInput;
There's two variables being de-referenced here
Try logging both and see which one is null
how do i log them?
Debug.Log(whatever you're logging)
Debug Log should literally have been the first line of Unity code you ever wrote
i think the issue there is the camera, you'd have to reference it in another way
If the camera were the problem, the null reference exception would be in awake when they try to get .transform from it
yeah you're probably right, do try logging though
i think i fixed it
i forgot to add one of the scripts to the character
now i can move it too
the camera doesn't move though
i'll work on that
thanks guys
how come rigidbodies are allergic to stopping
my bullets hit the ground and rotate along a flat plane forever
where is code question?
also should probably put up angular drag higher
Preservation of momentum? Do bullets stop when hitting the ground in real life?
is the best way of solving this issue making an empty game object and then having it go to location i need and then using Instantiate(_pointer, _gameobject.transform)
https://paste.mod.gg/rmumgusyoauz/0
A tool for sharing your source code with the world!
What issue?
i commented out the error i got at the bottom
hi guys
When sharing errors, please provide them outside the code sharing site, ideally a screenshot of the error and it's details(like a callstack), so that we have the whole context.
can you help me how to make annotation and line renderer in unity
ah sorry
What do you mean by annotation?
And is your issue code related? If it's about using line renderers in general, start by asking in #💻┃unity-talk
Provide more details/better explanation too.
wait oops i read that as animation, sorry
sure
Hey so is there a way to make it so that an input axis will just instantly go to zero when nothing is being pressed instead of the smooth return to zero?
Start using GetAxisRaw instead of GetAxis
GetAxis has smoothing
OK thanks
Didn't see chat I did essentials and now I was doing the junior scripting
https://paste.mod.gg/nbcshkglmwaw/0
how do i use the values of _pointerSpawn.transform.position inside the Instantiate?
A tool for sharing your source code with the world!
why does it say Scene instead of the animation name?
so i got this code where im trying to play a different sound depending on how high i slam from , so if i slam from a not so high ground then play the small calm slam sound but if i slam from high ground then play the aggresive big slam sound, for some reason even if checked everything , the big sound sometimes works fine but then decides to not work fine
pass it in as a parameter
Log the value of max shake magnitude when slamming
already doing that and it works fine , if i slam from high ground , it goes above 1 and if i slam from not a high ground then it goes below 1
could you show me an example
Instantiate(prefab, position, rotation)
It's spelled out in the docs: https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Object.Instantiate.html
and your IDE should show the options too
i misunderstood lol, thanks for the help
welp... idk why it's doing this
Whatever animation you are trying to use is 0 frames long - no animation
Which would probably be why you are getting that the 'position' is out of range
I've watched the video but I'm not sure what's not working. I'm assuming your question is in regards to why the small sound is playing when expecting the big sound.
yeah that , but i was playing around trying to find the issue and it seems like after some slams , the max shake magnitude is always 0.25 for some reason and doesnt go up even if i slam from a higher ground
It shouldn't be empty, i'm exporting it straight from blender and using an animation helper plugin.
So before the dynamic slam strength is declared and initialized: log the value of the distance to ground, slam strength and maximum strength.
If maximum strength had somehow become 25, you'd get 25 as the dynamic slam strength and max shake magnitude.
Or if the product of slam strength and distance to ground were below the minimum strength (25), you'd always get that value etc.
yeah i tried everything i could think of, idk how to properly export animations even with the animation helper that I am using
Here's what I found online
"It is possible that the frame rate in blender is lower than what you have set in Unity. Try changing the FPS in blender to 60."
tested it out , left ss is when i tested it on a smaller ground and right ss is when i tested it on a higher ground
it is set to 60 already
Check the value when it's misbehaving
hi sorry to interrupt anyone im not sure if im in the right place for this im working on a project for school this is not my major thank goodness but i got stuck with the code of the game in the project we are making and im not sure about 2 things when i put '.m_BoundingShape2D' i get and error also player.transform.position; and newPos is giving me an error as well any solutions ?
What's Vector3 newPos -player.transform.position supposed to do?
Hover over m_boundingshape2d and tell us the rrror
in need the player to move in front of a boundary i have set, basiclly they walk into the first boundary that switches cam positions and then there's another bound that if they walk into that it would switch the positon again so i need to move the player in front of the second boundary thats what its for i hope that explains it
You're missing the equal symbol if this was meant to be the declaration and initialization of a variable.
Vector3 newPos = -player.transform.position;```
thank you now im still not sure about this error
Also, I'm not sure about the 2d variant but the 3d confiner is expecting a collider2d but you're trying to assign it a cinemachine confiner 2d (?) apparently. Show your updated code.
https://docs.unity3d.com/Packages/com.unity.cinemachine@2.1/api/Cinemachine.CinemachineConfiner.html the docs for the 3d variant
I'm assuming you accidentally changed the type for map boundary to confiner 2d when the error was produced, script hasn't been saved or something else
It looks correct in the image you have shown but the error indicates otherwise because Polygon Collider 2d definitely inherits Collider 2d. https://docs.unity3d.com/6000.0/Documentation/ScriptReference/PolygonCollider2D.html
Can you show an update of your script?
Specifically, we need to see the field declaration and current error line after the script has been saved.
can anyone help me learn how to make a first person walking script i cant find any good tutorials
Sorry my wifi cut out...
I'll look into these methods and decide which one works
does anyone know how to help with this
First person character controllers are like 90% of all videos containing the wodlrs "Unity" in the title
yeah but i still cant find one
I'm pretty sure I could trip over seven of them on my way to the bathroom if I'm not careful
Where are you looking that there are none. Show your search results
I'm not sure which version of cinemachine you're using but according to blue the new field should be BoundingShape2D instead of the older m_Bou...
they are all either about animations or i tried and dont work but i did it correct
i tried and dont work but i did it correct
Most likely you didn't do it correctly
but i did i looked over it like 6 times
you would have to show a tutorial you tried and what you did and what happened
you made a mistake 6 times then
Everything except the third result there will do what you want to do
That third one is animations, but all the rest are character controllers that'll work
https://www.youtube.com/watch?v=f473C43s8nE
the character just falls dont and the camera doesnt work
FIRST PERSON MOVEMENT in 10 MINUTES - Unity Tutorial
In this video I'm going to show you how to code full first person rigidbody movement. You can use this character controller as final movement for your game or build things like dashing, wallrunning or sliding on top of it.
If this tutorial has helped you in any way, I would really appreciate...
you did it wrong
the second one is animation
all my scripts were correct and my hierachy was the same as his
false
prove it
how do you know
sure
It contains animation but I think it covers movement as well
It's the most common plausible cause for YouTube video tutorials working but the user's copy not working - human error.
I literally keep a running tally of this
im pretty sure this is the exact same (other than my model because its not a capsule like his)
yes thats my question
Okay and what is the issue with yours that theirs doesn't have
When you do a tutorial you should start by copying it exactly
don't start changing things until you get the tutorial working and you understand the whole thing
i havent changed anything
You're not using a capsule, for one
other than adding a collider to my model so it wouldnt fall
yeah but if it doesnt work with my model than i wouldnt need it
because i like my player model
The player model is irrelevant
why
it's a first person controller
first off
second off - the movement etc is capsule based
but it will be multiplayer
You need to learn to crawl before you start doing olympic marathons
worry about that later
i know how to crawl
trust me it's not relevant
If you can't make a first person controller, you are still learning to crawl in Unity
Where did you add the collider and what kind
so i spent a long time learning blender and my models are irrelevant
your models are irrelevant for the thing you're trying to do right now which is make a first person controller
i tried mesh and box but they dont work and i tried on the character and the model
so then how will i implent them later on?
Use a capsule collider on the object the object the tutorial says to put a capsule collider on
The actual model doesn't matter, only the collider is relevant for movement
Get the tutorial working first. Not wing it as you go
It'll be easier to eliminate issues that way
Also, which objects have these two scripts on them? And what is the issue you're having with them?
yes you'd have to also show that each object has the right components, and that the fields are all assigned correctly
i have implemented the capsule and done the tutorial but it still doesnt work
show the objects
we need to see the inspectors of the various objects to make sure you've set them up properly
And say what the actual problem is
you should also be more specific about what "doesn't work" means
Do you fall through the world, aren't able to rotate, not move, camera doesn't follow etc
wait i spoke too soon it works
thank you guys for your help
Assets\Scripts\InputManager.cs(58,34): error CS0117: 'Color' does not contain a definition for 'FromArgb' WHAT?
Correct, it never has
Color does not contain a definition for FromArgb
new Color(1f,0f,1f);
Assets\Scripts\InputManager.cs(59,46): error CS1503: Argument 2: cannot convert from 'double' to 'float
you're using the wrong Color class probably
check your using directives
using System.Collections.Generic;
using UnityEngine;```
Gizmos.DrawWireSphere(hit.point, 0.2);
and a runtime error, great
fixed that issue though
UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c__DisplayClass7_0:<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr)```
show the rest of the stack trace
UnityEngine.Input.get_mousePosition () (at <0b0249d5e61a446b913cd2910a5a40f5>:0)
InputManager.SelectItem () (at Assets/Scripts/InputManager.cs:56)
InputManager.<OnEnable>b__9_2 (UnityEngine.InputSystem.InputAction+CallbackContext i) (at Assets/Scripts/InputManager.cs:27)
UnityEngine.InputSystem.Utilities.DelegateHelpers.InvokeCallbacksSafe[TValue] (UnityEngine.InputSystem.Utilities.InlinedArray`1[System.Action`1[TValue]]& callbacks, TValue argument, System.String callbackName, System.Object context) (at Library/PackageCache/com.unity.inputsystem@1.0.2/InputSystem/Utilities/DelegateHelpers.cs:51)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)```
Seems pretty straightforward
your code is trying to use Input.mousePosition but you switched to the new input system
strange as the tutorial i am watching used that just fine somehow
Their player settings might be set to both whereas yours isn't
so what do i remplace 'Input.mousePosition' with then?
Mouse.current.position.ReadValue()
what the actual...
Assets\Scripts\InputManager.cs(56,57): error CS0103: The name 'Mouse' does not exist in the current context
i swear i attract all the errors and i hate it
i just want to make a cool game
Are you missing a using directive?
this is what i have
you need to learn to fix this kind of issue quickly
your IDE will automatically suggest the fix
follow it
i'm using Visual Studio and it has zero context on what is and is not valid, idk how to set it up properly
in fact, while typing that your IDE should have suggested the Mouse class with the correct namespace
!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 don't even see a workloads tab
where are you looking
i looked in unity, and on visual studio (on the hub) and when it's open for a new project
oh i thought it meant if i already had it installed
Having IDE makes this so much easier
Im pretty sure the server doesnt allow files
oh my bad, should i do screenshots instead?
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
it's not that we don't allow files, but they just aren't a good way to show what you have
though, i'd recommend you wait until you can get back on PC so you can actually test stuff or give more info from your project
ill get back on rn i just figured it would take a lot longer for a response so i got off
This channel is quite quick with responses in my opinion
eh it fluctuates with time of day lol
this is my first person camera script:https://paste.ofcode.org/rw5S3YhQFRqWrAR3idJHaZ
and this is my third person script:https://paste.ofcode.org/QWSuu9qWYXgYMh3xFPq5Je
and my camera swapping script if it matters at all:https://paste.ofcode.org/Zjn854yFHzv5LrGvcMrEdg
so what's the actual issue exactly?
the way my game is set up its going to be a co op fps tps shooter kind of like fallout is, right now in a host/client instance of the game i have set up through relay, when both of us look around in first person it doesnt show either of us actually looking around, however in third person everything works perfect. im not sure exactly what im missing
you mean you can't see the player rotating on the other player's screen?
WHich object is your code actually rotating
and is that object network synced
and is the rotation synced for it
Also does the object you are rotating have any connection at all to the visual object you expect to rotate
I see this:
private void LateUpdate()
{
if (playerRoot != null)
playerRoot.rotation = Quaternion.Euler(0f, yaw, 0f);
if (headBone != null)
headBone.localRotation = Quaternion.Euler(pitch, 0f, 0f);
if (IsOwner && fpsCam != null)
fpsCam.transform.localRotation = Quaternion.Euler(pitch, 0f, 0f);
}```
I would guess for one that the camera is not visible in any way, so the up and down pitch look certainly won't be visible
similarly for the headBone - you would need to be syncing that
and playerRoot
im rotating the player root and yeah i have a network object on it as well
yes
with what settings
the only way ik to do this is w screenshots so
What doe this hierachy look like, and what is your network topology?
if third person works properly I would really just guess that the two scirpts are rotating different objects.
Oh also:
SendYawToServerRpc(yaw);```
im running a host client set up where i host with unity relay and he uses my code to join me
your third person controller is doing it with an RPC for some reason
would it be best to use an rpc for fps as well
Network topoly means something like "Client authoritative" or "Server Authoritative"
It would be best IMO to use an RPC for neither
client then
#archived-networking is a better spot for this btw
i just dont think its an issue with the networking, i feel like its in the scripting because idk how my third person one would work and the fps not
it's an issue with networking and its interaction with your code
your code is not doing what it needs to do to effectuate a change in the rotation of the object over the network
then what is my third person code doing that my first person doesnt
well as mentioned it's doing the RPC
for one
for two it might just be rotating the correct object
it's hard for me to know just from seeing the code which objects are actually being rotated
because I don't know which object each script is attached to nor which objects are being referenced in the inspector
they are both set up the same way under fpscam and tpscam, with the root object set as my military character
also are both of these scripts active at once
they are only active based on what camera im on, i use camswap to disable the non active pov
could it be because my p1cam updates netLook.Value on the server but it doesnt update the local yaw/pitch on the server
im genuinely lost on how i made it work on one camera but not the other
Well I noted that RPC thing a while ago have you tried that?
networking is very hard 🙂
thats why im trying to figure it out first, so that way i can have all that worked out before i start adding everything else in. i am trying to see if i can get it to work differently with and without the rpc but it seems to do the same
welp, any ideas, so i am making a tower defense game, so i got the enemys path, i made it so that it goes in order of the stuff inside the parent, do i have to sort it manually?
you made it so what goes in the order of stuff inside what parent?
What are you trying to figure out here or achieve?
i am going to explain it clearly, sorry for my vague explanation earlier, so i got towers spawning , they are supposed to go on the path shown in the picture (i dont have intersect texture yet) the way i programmed is for the code which is attached to the enenmy, to find the tag "Path" which is attached to the parent of the road, you can see it in the picture, its called Enemy path. after it finds the tag, it goes through the children in order, here comes my problem, it takes a bit of time to do it manually, is there any other ideas, beside timeline
I wouldn't use tags for this
basically you would need to build a graph representation out of this
yeah, see all those prefabs, i am re arranging them naually
and then you can do any off the shelf pathfinding algorithm like Djisktra's or A* on the graph
i used 1 tag on the parent
i am a beginner, i didnt achieve that level yet...
you should use a tilemap
and then you can just do a pathfinding algorithm on the tilemap grid
If you want to make a tower defense game you'll have to learn pathfinding
i see, thank you, i will try to learn about it
The other option is to manually order them yes
but that's going to be a huge pain in the ass
pain to create, pain to maintain
also how would it work for the intersection parts?
yeah, agreed, i guess i will try to learn them
you could certainly do a waypoint-based system
i just got a empty parent, no texture, so yeah
that might actually be better for this - if they need to loop
i still tryna make the texture, the picture i provided uses asset store, i just dont know where to edit stuff inside unity, i tried importing it into blender
yeah i got it twice as shown in the picture
I added a debug log to show the pitch and yaw it is sending to the server, it is constantly showing the right values but the rotation isnt changing still
tf?
use mp4 so it can be embedded in discord
pretty sure it does, if you can't find it you can just convert the file you have online
bad code presumably
`using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Enemy))]
public class EnemyMover : MonoBehaviour
{
[SerializeField] List<Waypoint> path = new List<Waypoint>();
[SerializeField] [Range(0f , 5f)]float Speed = 1f;
Enemy enemy;
// Start is called before the first frame update
void OnEnable()
{
FindPath();
returntostart();
StartCoroutine(PrintwaypointName());
}
void Start()
{
enemy = GetComponent<Enemy>();
}
void FindPath()
{
path.Clear();
GameObject parent = GameObject.FindGameObjectWithTag("Path");
foreach(Transform child in parent.transform)
{
Waypoint waypoint = child.GetComponent<Waypoint>();
if(waypoint != null)
{
path.Add(waypoint);
}
}
}
void returntostart()
{
transform.position = path[0].transform.position;
}
void finishPath()
{
gameObject.SetActive(false);
enemy.StealGold();
}
IEnumerator PrintwaypointName()
{
foreach(Waypoint waypoint in path)
{
Vector3 startPoisiton = transform.position;
Vector3 endPoisiton = waypoint.transform.position;
float TravelPercent = 0f;
transform.LookAt(endPoisiton);
transform.position = waypoint.transform.position;
while(TravelPercent < 1f)
{
TravelPercent += Time.deltaTime * Speed;
transform.position = Vector3.Lerp(startPoisiton, endPoisiton, TravelPercent);
yield return new WaitForEndOfFrame();
}
}
finishPath();
}
}
`
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
https://paste.ofcode.org/HzuRqGzcdN9PKBZfLU2hiS
mb , does this link work the code i just uploaded? try it
yield return new WaitForEndOfFrame();should beyield return null;- You're setting
transform.position = waypoint.transform.position;before the while loop for moving 🤔
Also do your enemies have a Rigidbody on them?
ah i see, let me try those real quick
no
nothing works :/, any other ideas, i believe that tehy are moving according to their path, but then the code basically yanks them back because appartley they are "supposed" to be there
not sure what you mean by that
so idk if you saw in the video how the "Ram" twitches, i think something is conflicting in the code or like that, i am not too sure
You should double check there is no movement code on any other script as well
also Lerp isn't really appropriate here unless you can guarantee the waypoints are perfectly evenly spaced
MoveTowards would be better
there's nothing in this script that would be conflicting
there might be something in another script
i got 3 scripts, i just checked, nothing is interfering in the movement from other scripts
yeah pretty sure they are, i used snap grid throughout building it
yep they are evened, i just checked
regardless your "speed" is now expressed in terms of 1 / waypointDistance instead of just being an actual speed this way
also is any other script enabling/disabling this component by the way?
perhaps it's best if you just share the rest of your code
i mean, is there a way i can upload the files?
using the paste site as you did before is fine
do i give all codes in the project?
the three scripts on the enemy would be a good start
sure
wait a miute
i think i found out the problem
ah fuck my life
i had to of the mover script on my "ram" each one had a diffrent speed, :/
yep that'll do it
sorry for troubling you 🙏
building the game on Unity 6 suddenly always ends on
Running Backend without any messages, how to fix this
[it was originally 2023.2.20f1]
Hi, does anyone have any idea whats causing the jittering on objects when moving and looking around with the camera? im using a rigid body on the player and here is my movement and camera code:
void Update()
{
if (!isLocalPlayer) return;
HandleLook();
}
void FixedUpdate()
{
if (!isLocalPlayer) return;
HandleMovement();
rb.angularVelocity = Vector3.zero;
}
private void HandleMovement()
{
Vector3 move = new Vector3(moveInput.x, 0, moveInput.y);
move = transform.TransformDirection(move);
Vector3 targetVelocity = move * moveSpeed;
Vector3 velocity = rb.linearVelocity;
rb.linearVelocity = new Vector3(targetVelocity.x, velocity.y, targetVelocity.z);
}
private void HandleLook()
{
Vector2 lookDelta = lookInput * lookSensitivity * Time.deltaTime;
transform.Rotate(0f, lookDelta.x, 0f);
cameraPitch -= lookDelta.y;
cameraPitch = Mathf.Clamp(cameraPitch, -85f, 85f);
if (cameraHolder != null)
{
cameraHolder.localEulerAngles = new Vector3(cameraPitch, 0f, 0f);
}
}
Can you take a screenshot?
- Rotate the object via rigidbody methods, not transform.
- Enable interpolation on the rb.
- Don't multiply mouse input by deltatime
nevermind, I just accidentally had turned off errors here lol
you need to trim it down and find out what causes it by testing each method seperately, first the HandleLook then HandleMovement. Then you can easly find out what causes this unwanted behaviour.
also i would change the order of these 2 lines
cameraPitch -= lookDelta.y;
cameraPitch = Mathf.Clamp(cameraPitch, -85f, 85f);
thank you, i did what dlich said and rotated via rigidbody instead of transform and removed the multiply by deltatime and it is much better, there seems like theres a little jittering still but that might just be my eyes messing with me lol
Hello! I've had a bit of an "issue" of serializing a dictionnary and followed an idea of having two seperate lists as [SerializeField]. Would it be possible to have a common size, so that if I change that size value in the inspector it also increases the size of both lists?
No. You would have to make or use a custom inspector
damn so I do have to use the custom Dictionnary then :/
you can use the existing SerializedDictionary plugin, or you could use a list of structs instead as well
Is it an already existing asset?
Just make a struct with key and value then make the dictionary at runtime
my goal is to be make buildings class hold their ressources need and cost
if possible I want to make prefabs of them
Array of structs that hold those values -> initialize dictionary in awake
so i really need some help. idk why but my Character jumps in the air. I've watched every single video on youtube. asked Chat Gpt and much more but i never risolved it. And i need to finish this as a School Project so i really could use some help.
so something like this:
struct pair{
private ressourceType key;
private int value;
}
is this an optimal way of adding force if im using velocity to move the player? (im worried because the debug.log(force) stops giving readings once it is less than 3)
Is there a reason you're setting velocity if you're using forces
use debug logs, for is grounded and wasgrounded
seems like you are playing animations when you should not.
i would simly move the logic from the !isGrounded if statement into the if statement on line 41 and get rid of the was grounded part
I can't see the array in the inspector, am I doing something wrong?
[SerializeField] private List<pair> ressourcesCosts;
struct pair
{
public RessourceInfo.ressourceType ressource;
public int amount;
}
oh do I put it in front of struct?
Before it, ye
kk thanks!
so i should put the animator.SetBool("Jump", false); into the is grounded part? or am i understanding u wrong
i would use a Trigger to play the jump animation instead a bool that you have to set back
this is the part that causes the problem , the wasgrounded and isgrounded part
so the animation now works but i dont know why my character is still jumping in the air
show your new code (as codeblock or use a codebin)
!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/, https://scriptbin.xyz/
📃 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 the code
it is still messy, you are still using both bools and please send code instead image of code
oh wait a sec then.
This video should help >
https://youtu.be/0CDvSM9kEpU?si=Xypsurd8ea4RerTN
I've been playing around with different camera configurations in Unity to achieve a non-jittery camera and I think I might've come across the best solution.
Timestamps:
0:00 - Introduction
0:42 - Chapter 1: Understanding the problem
1:45 - Chapter 2: FixedUpdate vs Update
4:56 - Chapter 3: The solution
5:17 - Chapter 4: The solution part 2
6:18...
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public Animator animator;
public float moveSpeed = 5f;
public float jumpForce = 10f;
private Rigidbody2D rb;
private SpriteRenderer spriteRenderer;
public Transform groundCheck;
public LayerMask groundLayer;
private bool isGrounded;
private bool wasGrounded;
void Start()
{
rb = GetComponent<Rigidbody2D>();
spriteRenderer = GetComponent<SpriteRenderer>();
if (groundCheck == null)
{
Debug.LogError("GroundCheck object is not assigned.");
}
}
void Update()
{
wasGrounded = isGrounded;
isGrounded = Physics2D.OverlapCircle(groundCheck.position, 0.2f, groundLayer);
float horizontalInput = Input.GetAxisRaw("Horizontal");
rb.linearVelocity = new Vector2(horizontalInput * moveSpeed, rb.linearVelocity.y);
if (horizontalInput > 0)
spriteRenderer.flipX = false;
else if (horizontalInput < 0)
spriteRenderer.flipX = true;
if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
{
rb.linearVelocity = new Vector2(rb.linearVelocity.x, 0f);
rb.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse);
animator.SetTrigger("Jump");
}
animator.SetFloat("Run", Mathf.Abs(horizontalInput));
if (!isGrounded)
{
animator.SetFloat("VerticalVelocity", rb.linearVelocity.y);
}
else
{
if (!wasGrounded)
{
animator.SetTrigger("Land");
}
}
}
void OnDrawGizmos()
{
if (groundCheck != null)
{
Gizmos.color = Color.red;
Gizmos.DrawWireSphere(groundCheck.position, 0.2f);
}
}
}
I fixed mine by using cinemachine
thank you ill give it a look, seems to get it pretty much as i want it now
yeah.. i'd have to use drag to slow the player back down.. and that messed up a lot of stuff (basically i couldnt find a good tutorial) i tried velocity and it worked perfectly soo...
so where is the problem?
hello, how can i make growing objects that stops if it cant grow anymore, like when it ran out of space to grow it stops growing in 2d
If it has space on one side but is blocked on another side, should it keep growing towards the free space or stop growing completely?
And what shape is it
i would like it to continue
just a simple square
something like this
You could do a Physics2D.OverlapBox on each side of it
And grow towards the sides that weren't blocked
BoxCast is also possible and can be more accurate for this but is more complex to implement
what's the difference?
BoxCast is like RayCast but it shoots a box
So it can tell you how far the box "traveled" before it hit anything
While OverlapBox only tells you if anything was in the box area you checked
Alright so Ive got the basic direction I wanna go with design, but I don’t know where to start in coding
You !learn the basics before jumping into making your game.
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
//audioSource.clip = self.SoundEffects.JumpSound; // self is the component same component as this script
why does this not work
it says it needs an object reference but i gave that right?
it's commented out
no not in the original code
i did ```cs
// Your code here
like it said
but why does it not work
audioSource.clip = self.SoundEffects.JumpSound; // self is the component same component as this script
why does this not work
you aren't supposed to make it a comment lol
i fixed it
show the actual error instead of paraphrasing
You appear to be trying to access an instance variable with the class name rather than a variable
Huh?
Also you don't need to make a self variable, C# has this as a keyword
also show the relevant code rather than just the one line
are you calling this from a static method
public class move : MonoBehaviour
{
public class SoundEffects
{
public AudioClip DashSound;
public AudioClip JumpSound;
}
does this help
Do you have a variable that holds an instance of SoundEffects
DashSound and JumpSound are instance variables, so you cant access them via the type SoundEffects
is there a reason this is even a class
just put the dash sound and jump sound inside Move and capitalize Move to keep it consistent
Then you don't have access to those variables because they only exist on an instance of SoundEffects
so my component does not get to long and scuffed
It's in the same file. It's going to add more length, not less
You probably shouldn't use nested classes until you've fully grasped the difference between a class and an instance
but it is collapsable
So is a region
Instance?
i dont know anything i realize
A class is not an object. It's a pattern that tells an object what it can do. Until you create an instance of the class, it does not exist
Unless you have created a new SoundEffects() somewhere, this object does not exist
A blueprint of a house is not a house
i think i want to use that i think
there are other ways to organize your components, like through editor code. all you're doing here is making the coding part worse
think they were talking about in inspector
It wouldn't be in the inspector at all
unless im remembering wrong
It's not serializable and they don't have a variable that can hold one
either if its for seeing in your IDE or inspector, you wouldnt want to just make classes like this because it becomes more annoying to write. For now you should definitely avoid classes within classes
Ok
i checked , the value starts when i pressed the slam key and then it goes down from there
if (dataFloatActive[i] < (6 / 255) || dataFloatActive[i] >= (249 / 255))
{
floatSmoothingMultiplier[i] = 0; // Set to 0 here
}
if (dataFloatActive[i] <= 30/255 && dataFloatActive[i] > 6/255)
{
floatSmoothingMultiplier[i] = ((dataFloatActive[i]-6/255)/((30-6)/255))* floatSmoothingMultiplier[i];
}
if (dataFloatActive[i] < 249/255 && dataFloatActive[i] >= 225/255)
{
floatSmoothingMultiplier[i] = -((dataFloatActive[i] - 6/255) / ((255 - 6)/255))* floatSmoothingMultiplier[i];
}
else
{
floatSmoothingMultiplier[i] = 1;
// if not in these ranges, smoothing is unchanged
}
// Finish Dynamic Smoothing
Debug.Log(dataFloatActive[0]);
Debug.Log(floatSmoothingMultiplier[0]);
Is this a valid IF statement?
I am trying to change an array indices 'floatSmoothingMultiplier' to be a function of the corresponding indices in the array 'dataFloatActive'
The values in 'dataFloatActive' range 0-1, and the floatSmoothingMultiplier is set to 1 before this block of code
Outputting 'dataFloatActive' at the indice of 0 into the console shows that it does change properly when triggered, but it either uses the 'else' portion of the statement, or uses the first 'if' statement if the 'else' is empty
The math does work properly if it is forced, but the if statement just.. doesnt work?
6 / 255 is 0, 249 / 255 is 0. If there is no float in the operation, you will be hitting integer math, which has no decimal places.
both of these arrays are declared as 'public float[]' near the start of the script im modifying
in the console, 'dataFloatActive[0]' is outputting 0.0196, which corresponds to the 5/255 I am inputting. The second value in the pair, which is stuck at 1, is the floatSmoothingMultiplier[0]. But in the if statement, it should be 0?
If I make the else statement empty, it gets stuck at 0
if all of the variables/arrays here are floats, should it work? Or am I still missing something?
Should I declare the variables its comparing to as floats, then put them in?
you can put f at the end like 6f/255f
it doesnt matter that dataFloatActive[i] is a float. (6 / 255) is still 2 ints so the result is an int, thus 0. Afterwards its compared to with dataFloatActive[i] < (6 / 255) so its dataFloatActive[i] < 0
ah ok
can anyone help me with my portal not changing scenes even tho it's working on other levels
post some code please
void Update()
{
}
private void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.CompareTag("Player"))
{
SceneManager.LoadScene("Level 9");
}
}
Were there any errors?
Maybe the other object wasn't tagged "Player"?
nope i made sure it was tagged
Place a log to see if it occurred and what the tag of the object was
i am assuming the scene doest exist.
Ah, then if I put an f after every number in the operation, it should all be floats and work?
nah the scene does exist. can i share my screen somewhere bc i suck at explaining im sure the fix is simple i'm just not seeing it
check the "scenes in build" window and see if the scenes you try exist there
i did that and they all are there
You'll need to provide some info for us to check where you might have made a mistake.
private void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.CompareTag("Player"))
{
Debug.Log("working");
SceneManager.LoadScene("Level 9");
}
}
this could give you a hint
aight let me try it out
This is the beginner coding channel. You should probably move your message to #💻┃unity-talk or #🏃┃animation
oh ok👍
spamming your post is not acceptable either, please remove your posts
aight so this is what i got
cause i was testing with multiple colliders to see if one of them was the issue
Show screenshots of the inspectors of the two objects involved so I don't need to fish for them in the video
realistically it should work if you put it on just one of the two but yea might as well do it on all. the f at the end makes it a float
that was literally something else i was trying to find out
And how are you moving the player object?
with a Movement script
Yes but how is the movement being done
Through the rigidbody or the transform
Also,
Not going to get a collision event with that
through both
Don't
aight let me turn it off
wdym
Don't use transform to move an object with a rigidbody on it
Transform teleports and object and doesn't respect the physics engine/simulation
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
for some reason both of the Debug.Log's are running
void OnJump(InputValue value)
{
// Can jump only if player collider is touching ground, preventing multi jump
if (value.isPressed)
{
Debug.Log($"IsGrounded: {PlayerState.Instance.IsGrounded}");
// checking for valid jump coniditions
if ((PlayerState.Instance.IsGrounded || PlayerState.Instance.IsOnRail) && canJump)
{
Debug.Log("Running typical jump");
PerformJump();
canJump = false;
} else if (canJump) { // these are performed in the case that a normal jump should've gone through but didn't cause the conditions weren't met
JumpBuffer();
ApplyCoyoteTime();
canJump = false;
}
PlayerState.Instance.IsJumping = true;
}
}
specifically in this part, even though I have an if statement
So it ends up printing out both "Running typical jump" and "applying coyote time", when it's only supposed to apply the coyote time when I'm slightly late on my jump
Then what you think the if should do is wrong if its printing both 🤔
its currently (is grounded OR is on rail) AND can jump)
correct but I see no log in the else if(canJump) section above
I'm sorry I posted the full code above
but essentially there's a log for "Applying coyote time" elsewhere
void ApplyCoyoteTime() {
// if they're not touching any layers and the time since they've been falling is less than the allowed coyote time
// perform a jump
if (PlayerState.Instance.CheckIfNotTouchingLayers() && timeSinceStartedFalling < jumpBufferTime && PlayerState.Instance.TimeSinceLeftJumpableSurface() < jumpBufferTime) {
Debug.Log("Applying coyote time");
PerformJump();
}
}
right there
Have you used a debugger to check what is happening?
Unity has a debugger?
Your IDE has a debugger (e.g. visual studio, visual studio code, rider)
https://docs.unity3d.com/6000.0/Documentation/Manual/managed-code-debugging.html
screenshots bad !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/, https://scriptbin.xyz/
📃 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.
share it properly 🤦
Ohh ok ok sorry
@true owl kind of strange your if statements can you explain what you want, you are checking for canjump then again else if canjump
you could put the canjump into the very top if statement if (value.isPressed)
these kind of things are small but have big impact and can solve things easly
especially when you have a lot of code
yes so essentially i have a normal jump which is the case where the player is on the ground and space is pressed, but the other case is when it's not exactly on the ground like if the player has buffered a jump which is not touching the ground but close enough (raycast) and coyoteTime which is when they leave the platform but input jump so we just give it to them
so the issue is it's pretty much supposed to print either "Running typical jump" or "applying coyote time"
but it prints both resulting in a huge jump
only when i am just barely off the ledge (the coyote case)
so i have my movement setup as a state machine but the coyote time is really easy since i just let a jump still happen if a jump has not been used and you have been in the falling state for less then a very small amount of time
isn't that kinda the same thing I'm doing?
I apply the coyote time with that same logic
PerformJump() contains the actual logic for jumping
and it's called within ApplyCoyoteTime() if the conditions are met
yeah so more or less the same, i did not look at the code, and reading above i thought you were trying to like do it based on distnace or somethign
oh no, it's the same thing based on time passed since left platform and in falling state
though i feel your buffered jump sounds a little odd since you are doing it with a raycast before you hit the ground
really what's wrong with it
it would allow them to get slightly more height then a normal jump
well it says that if there's a jump at this time, then wait till you touch the ground and do a normal jump
so it's the same
I think
ah why the need for a raycast
it checks if there's an input in this distance, which is basically the buffer I allow for an input
I thought the easiest way was a raycast
i did my simply as a if you hit jump and are not grounded it records what time it was pressed, then when you become grounded then it sees if its been recent enough to use it
that also makes sense
i feel like both are valid
I'd just rather deal with raycasts over times
it's easier imo
but yeah good movement code tends to get quite huge, not even feature complete for the one i am doing at work and its already 3kloc
ah okay gotcha
i appreciate the suggestion, I think i'm gonna stick with the raycast for now
i'll probably end up doing a refactor in the future
aight i did it now
ok so my player is moving down very slowly
when they are falling
You are probably setting the Y velocity to 0 somewhere in your movement code
post some code for us to inspect
moveDirection.y = 0; yeah hmmm i need to resume that tutorial
{
//Debug.Log(cameraObject +", " + inputManager.verticalInput);
moveDirection = cameraObject.forward * inputManager.verticalInput;
moveDirection = moveDirection + cameraObject.right * inputManager.horizontalInput;
moveDirection.Normalize();
moveDirection.y = 0;
moveDirection = moveDirection * movementSpeed;
Vector3 movementVelocity = moveDirection;
playerRigidbody.velocity = movementVelocity;
}```
yeah as digi said
Yeah, you should probably keep your old Y velocity around
instead of setting it to 0
God i'm trying to make a loading system for a revolver and my code is so stupidly ugly
private void Load()
{
int bulletsToLoad = weaponCapacity - loadedBullets;
if (bulletsToLoad <= storedBullets)
{
storedBullets -= bulletsToLoad;
loadedBullets = weaponCapacity;
}
else
{
storedBullets = 0;
loadedBullets += storedBullets;
}
}
There's gotta be a cleaner way to do it ugh
Sounds like you need mathf.min
Sorry lol lemme check the docs up to see how that'd work
could you please explain
No yeah how would you even use Mathf.Min in that context
It returns the smaller of two values
I know, but still, how'd you apply it?
You'd get the min of bulletsToLoad and Stored bullets, then subtract that from stored bullets and add it to loaded bullets. No if statement required
Like bulletstoload = mathf.min(
capacity - loaded,
stored);
Then just add and subtract bulletstoload from your tracked stored and loaded
You don’t need any checks because it will never be lower than 0 or make the loaded higher than capacity
And will at most be the correct amount to reload
{
floatSmoothingMultiplier[i] = 0; // Set to 0 here
}
if (dataFloatActive[i] <= 30.0f / 255.0f && dataFloatActive[i] > 6.0f / 255.0f)
{
floatSmoothingMultiplier[i] = ((dataFloatActive[i] - 6.0f / 255.0f) / ((30.0f - 6.0f) / 255.0f)) * floatSmoothingMultiplier[i];
}
if (dataFloatActive[i] < 249.0f / 255.0f && dataFloatActive[i] >= 225.0f / 255.0f)
{
floatSmoothingMultiplier[i] = -((dataFloatActive[i] - 6.0f / 255.0f) / ((255.0f - 6.0f) / 255.0f)) * floatSmoothingMultiplier[i];
}
else
{
// if not in these ranges, smoothing is unchanged
}
// Finish Dynamic Smoothing
Debug.Log(dataFloatActive[0]);
Debug.Log(floatSmoothingMultiplier[0]); ```
Ok tried it and.. still didnt work right
😨
??
The amount of spacing? or something else?
No sorry it's just seeing so many values makes my brain go dizzy
It's a me issue not a you issue dw
I’ve read your original message but I still don’t know what you’re trying to achieve
Ok so you’re just doing some funky maths to an array of floats from input numbers from an array of floats?
What’s the expected outcome and what’s happening instead
ok, so the dataFloatActive controls the position of the fixture at the bottom with red arrows pointing to it. Its angle is changed according to an input of 0-255, which is translated to 0-1 somewhere before my edit to this script.
The fixture is intended to smoothly go full circle multiple times, which translate to what is effectivley a sawtooth pattern if one were to plot the dataFloatActive value vs time.
The problem is that the floatSmoothingMultiplier being anything other than 0 when dataFloatActive switches from 0 to 1 or 1 to 0 causes the fixture to do a backflip to try to smooth it as if it tried going the other direction
I will say that your third if statement will never be true
It’s like if i is less than 0.98 and greater than 1
Can you explain in simple terms how you want the fixture to move
Because this solution does feel very unnecessary
Have you considered using animations
it uses animations, however the position needs to be controlled via DMX input (audio visual stuff).
I will get a video of it
Hi, I'm a beginner in this, does anyone know how to make the same door as in phaspomohbi? That you press the left button and it opens
could anyone help me? i wanna make a game but idk anything i just wanna make a simple chareccter w animation walk ing running crouching but idk how is there maybe someone who can help or a yt vid that tells how i cant find any
I would use the dot product of the player’s view angle and the direction from the player to the door
to get a ‘loose’ detection of whether the player is looking at the door
And use a trigger animation to open the door
You can't find any tutorials on making a basic character, or animating?
no every single one i have tried non work either i am the problem or it cuz all of them are old
do you have time to help me ?
or can you send me code to script?
It sounds like you might "be the problem"
If you don't know anything, start with something very simple, like a C# course, anything to get you familiar with the language will go a long way
then think about Unity
my favorite software dev saying: “usually the problem is between the keyboard and the chair”
Here's how to translate old tutorials to current unity:
- Replace
.velocitywith.linearVelocity
that's it that's the process
Only the new input system has changed in regards to what you’re trying to create, but the old input system is still usable so nothing in old tutorials should simply ‘not work’
cam somone help me with this? please
Most old things are marked as obsolete, and most have comments directing you to the correct field
A tutorial being old isn't usually a problem
ig i will try it again
In the kindest way possible, nobody is going to just tell you exactly what to click and exactly what to write
If you are truly beginner and wish to implement this
I would suggest you look into how raycasting works, so you can know if the player is looking at a door
And to look into animations and how to control them from scripts, to make the door actually move
i am gonna never give up with my door
If you understand vector maths, i would use this instead for detecting looking at a door, but if you don’t, no worries just use a raycast, it’s simpler to understand
okay thanks
wai- it was the wrong file format
This is the intended behavior, where the fixture is able to spin fully in circles. The animation only has it going 0-360 degrees, but the input is a sawtooth pattern, rising to 1, then instantly dropping to 0 to restart the cycle. This has the smoothing off.
At low speeds, it begins to become jittery. with only increments of 1.4 degrees available for the input, it jumps around if small changes are made. This is why I want to add smoothing to it
https://youtu.be/Kt27KSuHqmM
however, with smoothing at a constant, the fixture bounces around when crossing the threshold
https://www.youtube.com/watch?v=6tOxH_2FOXE
ok and what about it do you need to change based on user input?
What I am trying to do, is scaling the smoothing strength with respect to the current angle/value.
I am trying to make the smoothing reduce to 0 when the variable dataFloatActive gets close to 0 or 1
The console in the video is outputting the dataFloatActive, and floatSmoothingMultiplier
the floatActive is what controls the position of the animation/fixture
wait let me just confirm something you're NOT just wanting this to always be rotating like in this video right?
and just have it be on or off?
I want it to not bounce when it crosses over that threshhold, the constant rotation is an example movement
so why not just use the animation like in the first video? im confused
if that's the intended movement
yes, but the fixture wont always be moving that fast. The problem with it moving slowly is that it gets jumpy.
https://youtu.be/xqRnV2FTu2Q
The problem with adding extra animations for finer movements is that... I need to add an entire set of 36 animations, and add more asynchreadback entries, doubling the number from 36 to 72, which will likely cause performance issues
can anyone help me with this error?
i disabled burst, reinstall unity and delete my libary+obj but nothing works
how to fix.
step 1. Toss the UVC package in the trash.
step 2: Ditch Unity VC and use a proper VC like git
idk com.unity.collab is very old so idk whats happening there..
is that a stacktrace? what's visualscripting doing there?
Have you considered just adding to the rotation value?
(btw another guy with the same/similar issue in #💻┃unity-talk)
I have looked into it, and the nature of DMX and the scripts prevents that from being possible...
What do you mean
So i need to swap from UVC to git?
are you actually using uvc ?
Have no idea, im New in working with Unity and scripts 😇🥹
I would switch though if you are trying to collab via version control
have you heard of it before? or "version control", "collab", etc (in the context of unity)
Sadly no 😓
is that a brand new project though? maybe its something else
okay so I'm basically having this issue when he's sliding down the wall it will still apply the snapping, which I don't want. I think this is happening because of the raycast line being so thin it's hitting some very small area in between my blocks such that it's applying the snap, how can I fix this?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I cant fully explain, but the script im editing is part of VR Stage Lighting
It may be possible, but needs another script to track the rotation and to keep it going, and that is bund to fail at some point
and its not reccommended to do that
Its a new project and i work with it since 2 days
@formal plaza @rich adder may i suggest taking this discussion to #💻┃unity-talk? doesn't seem to really fit here (and also could expand to helping the other guy)
what the best practice for creating structures for loading data?
Having a "fresh save" file and giving the player a copy of one, or having a state or flag like "firstTimeInitialize" and have functions that generate the starting game state when the player loads without loading from an existing save file?
For what is UVC exactly?
hey, my friend and i trying to work tog on the same project using git but he gets this error "failed to find entry points" we trying to fix this for the last 5h but....
I really think you should attempt to explain why you’re unable to even if very simply. Is there no way to get some ‘speed’ value that you want the thing to rotate at? Having to have access to the rotation somewhere else is no issue with just using the transform so I’m a bit confused
Given that it says unity version control right there i would assume you might be using unity version control
im not, im using git
XD
Try backing up then deleting the library folder
i did just giving me another error and then returning to this error
not a code question, use #💻┃unity-talk