C
C#3mo ago
Ponge

Having issues with the [serializeField] thing

if someone can explain pls
No description
33 Replies
Angius
Angius3mo ago
No description
Angius
Angius3mo ago
Forgot a semicolon
Ponge
PongeOP3mo ago
omg its just that thx so much damn while you are here can you help me with that error
Sehra
Sehra3mo ago
one of the variables is likely a double so the rest is promoted to double as well, so Math.Sqrt returns a double and you are trying to assign it to a float
Ponge
PongeOP3mo ago
it recommend to write (float) it seem it fixed it is it normal that i have to create a lot of serializeField for many things ?
Angius
Angius3mo ago
In Unity? Yeah Anything you want exposed to the inspector has to be a SerializeField That said, if you don't want to expose something, no need for that attribute
Ponge
PongeOP3mo ago
oh okay sorry last question
Ponge
PongeOP3mo ago
No description
Ponge
PongeOP3mo ago
No description
Ponge
PongeOP3mo ago
why and thx so much for your past answer
Angius
Angius3mo ago
The error is quite clear
Ponge
PongeOP3mo ago
oh
Angius
Angius3mo ago
rb.linearVelocity is a float You're trying to give it a Vector2
Ponge
PongeOP3mo ago
ok so i erase vector2 ?
Angius
Angius3mo ago
Square peg does not fit round hole
Ponge
PongeOP3mo ago
ye but
Angius
Angius3mo ago
Idk, do you?
Ponge
PongeOP3mo ago
in tutorial video he does it ok i juste put = JumpForce it doesn't work he just goes in the air
Angius
Angius3mo ago
You sure it's suppossed to be linearVelocityY and not, say, linearVelocity? Double-check with the tutorial
Ponge
PongeOP3mo ago
actually it was linearVelocity.x now it says that :
Ponge
PongeOP3mo ago
No description
Ponge
PongeOP3mo ago
No description
Sehra
Sehra3mo ago
could try removing Vector2 so it only says new(...)
Angius
Angius3mo ago
Do you have a using System.Numerics reference? If so, remove it Would target-type new() work in Unity?
Ponge
PongeOP3mo ago
ok i try
Sehra
Sehra3mo ago
not sure which version unity use, probably something old
Angius
Angius3mo ago
Standard 2.0 IIRC
Sehra
Sehra3mo ago
seems like c# 7.3, so might not work
Ponge
PongeOP3mo ago
i have the latest one
Ponge
PongeOP3mo ago
No description
Ponge
PongeOP3mo ago
with this he also goes in the air the tutorial seems old i try will try with a more recent one thx for everything
Buddy
Buddy3mo ago
Don't follow tutorials blindly You will learn nothing from it Learn C# first then move to Unity when you feel ready

Did you find this page helpful?