C
C#3mo ago
efeessiz

Help with error

what is this error and how to fix it
No description
31 Replies
SamwiseTheBrave
SamwiseTheBrave3mo ago
you did not assign any object to a public field in inspector aka you have a public variable that's visible in inspector but it's empty
efeessiz
efeessizOP3mo ago
how to fix
SamwiseTheBrave
SamwiseTheBrave3mo ago
the error message literally says that you need to assign some object to it
efeessiz
efeessizOP3mo ago
But how..
SamwiseTheBrave
SamwiseTheBrave3mo ago
like, by drag and drop
efeessiz
efeessizOP3mo ago
im not blind i know how to read to where
SamwiseTheBrave
SamwiseTheBrave3mo ago
show me a screenshot of your ThirdPersonMovement script in inspector
efeessiz
efeessizOP3mo ago
k one min using System.Collections; using System.Collections.Generic; using UnityEngine; public class ThirdPersonMovement : MonoBehaviour { public CharacterController controller; public Transform cam; public float speed = 6f; public float turnSmoothTime = 0.1f; float turnSmoothVelocity; void Update() { float horizontal = Input.GetAxisRaw("Horizontal"); float vertical = Input.GetAxisRaw("Vertical"); Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized; if (direction.magnitude >= 0.1f) { float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg + cam.eulerAngles.y; float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime); transform.rotation = Quaternion.Euler(0f, angle, 0f); Vector3 moveDir = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward; controller.Move(moveDir.normalized * speed * Time.deltaTime); } } }
SamwiseTheBrave
SamwiseTheBrave3mo ago
public Transform cam; this field is visible in inspector by inspector I mean in Unity you have to grab object representing your camera and drag it to this field in Unity if you're following a tutorial it should be shown there
efeessiz
efeessizOP3mo ago
cant see public transform cam @WinForms Sam
SamwiseTheBrave
SamwiseTheBrave3mo ago
show me a screenshot from Unity where your script shows
efeessiz
efeessizOP3mo ago
No description
efeessiz
efeessizOP3mo ago
this?
SamwiseTheBrave
SamwiseTheBrave3mo ago
yes]
efeessiz
efeessizOP3mo ago
alr what now
SamwiseTheBrave
SamwiseTheBrave3mo ago
here
No description
SamwiseTheBrave
SamwiseTheBrave3mo ago
you have empty field for cam and for character controller
efeessiz
efeessizOP3mo ago
what do I do oh nvm cant change controller tho I can only change cam
SamwiseTheBrave
SamwiseTheBrave3mo ago
do you have a character controller?
efeessiz
efeessizOP3mo ago
cam is falling down when I run it no I just added
SamwiseTheBrave
SamwiseTheBrave3mo ago
check if you did everything as he did in tutorial
efeessiz
efeessizOP3mo ago
the cam is moving when I do wasd and its lagging when I do it I think I did.....
SamwiseTheBrave
SamwiseTheBrave3mo ago
you obviously did not since it's not working
efeessiz
efeessizOP3mo ago
can u add me so I can create a groupchat with my frien and he can screen share
SamwiseTheBrave
SamwiseTheBrave3mo ago
sorry, but I don't have that much time
efeessiz
efeessizOP3mo ago
ugh I straight copied the code that the tutorial man mentioned
SamwiseTheBrave
SamwiseTheBrave3mo ago
check if you assigned right camera and see if he perhaps did something more
efeessiz
efeessizOP3mo ago
do you want me to send any kind of ss cause I can barely understand
SamwiseTheBrave
SamwiseTheBrave3mo ago
watch what he did step by step I can't really help more, sitting here, miles away
Buddy
Buddy3mo ago
Do not blindly copy paste That's how you get stuck in tutorial-hell Understand what the code does. Also, do not learn C# in Unity. Please. I suggest learning by doing, $helloworld is a good start.
Want results from more Discord servers?
Add your server