C
C#5d ago
wyqsuy

✅CS1513 '}' expected

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

+namespace YourNamespace;

public class PlayerMovement ... {
using UnityEngine;

+namespace YourNamespace;

public class PlayerMovement ... {
is this clear?
wyqsuy
wyqsuy5d ago
what does it do?
ffmpeg -i me -f null -
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
cap5lut5d ago
the problem is actually the public static member in the Start() method, u can only declare members at class level
wyqsuy
wyqsuy5d ago
oh
ffmpeg -i me -f null -
aaaaa i missed that i thought "weird, namespace should be implicit"
wyqsuy
wyqsuy5d ago
that works
No description
wyqsuy
wyqsuy5d ago
i named it globalos because i already had a class named globals
cap5lut
cap5lut5d ago
u could also just make it a static field for PlayerMovement
wyqsuy
wyqsuy5d ago
i don't even know what that is
cap5lut
cap5lut5d 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()
{
// ...
}
}
wyqsuy
wyqsuy5d ago
thanks its working
cap5lut
cap5lut5d ago
and usually u would probably make it readonly and set it its value directly public static readonly Quaternion DefaultRotate = ....;
wyqsuy
wyqsuy5d 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
Want results from more Discord servers?
Add your server
More Posts