C
C#10mo ago
Chopsuy

✅CS1513 '}' expected

can someone help me with solving this?
No description
No description
21 Replies
Chopsuy
ChopsuyOP10mo ago
I was trying to stop an object from rotating with the transform.rotation and the defaultRotate
Ꜳåąɐȁặⱥᴀᴬ
remove all methods and add one by one, that's one thing you can try
Chopsuy
ChopsuyOP10mo ago
you mean Start() and Update()?
Ꜳåąɐȁặⱥᴀᴬ
even the class, eventually if you auto-format the file what does come out?
Chopsuy
ChopsuyOP10mo ago
how do u do that
Ꜳåąɐȁặⱥᴀᴬ
oh you're missing namespace ............. { after usings
Chopsuy
ChopsuyOP10mo ago
like that?
No description
Ꜳåąɐȁặⱥᴀᴬ
using UnityEngine;

+namespace YourNamespace;

public class PlayerMovement ... {
using UnityEngine;

+namespace YourNamespace;

public class PlayerMovement ... {
is this clear?
Chopsuy
ChopsuyOP10mo ago
what does it do?
Ꜳåąɐȁặⱥᴀᴬ
it's to give a name of the location where you are putting your code so in this case the full name of the class would be YourNamespace.PlayerMovement
cap5lut
cap5lut10mo ago
the problem is actually the public static member in the Start() method, u can only declare members at class level
Chopsuy
ChopsuyOP10mo ago
oh
Ꜳåąɐȁặⱥᴀᴬ
aaaaa i missed that i thought "weird, namespace should be implicit"
Chopsuy
ChopsuyOP10mo ago
that works
No description
Chopsuy
ChopsuyOP10mo ago
i named it globalos because i already had a class named globals
cap5lut
cap5lut10mo ago
u could also just make it a static field for PlayerMovement
Chopsuy
ChopsuyOP10mo ago
i don't even know what that is
cap5lut
cap5lut10mo ago
public class PlayerMovement : MonoBehaviour
{
public static Quaternion defaultRotate;
private void Start()
{
// ...
}
private void Update()
{
// ...
}
}
public class PlayerMovement : MonoBehaviour
{
public static Quaternion defaultRotate;
private void Start()
{
// ...
}
private void Update()
{
// ...
}
}
Chopsuy
ChopsuyOP10mo ago
thanks its working
cap5lut
cap5lut10mo ago
and usually u would probably make it readonly and set it its value directly public static readonly Quaternion DefaultRotate = ....;
Chopsuy
ChopsuyOP10mo ago
yea but i think that i will leave it as it is cuz after that ill try to rotate the player not stop him from doing that

Did you find this page helpful?