void FixedUpdate()
{
Vector3 movement = new Vector3(movementX, 0.0f, movementY);
rb.AddForce(movement * speed);
}
}
Visual studio show that there is no problems detected as well as Unity
But when I click play it just won’t move
When i add speed the speed also show in the player inspector but no matter the number i put it
It just won’t move
This is my first time using Visual Studio and Unity as well as first time trying to run C# on Unity
I follow every step of the tutorials
My Unity version is 2020.3.19f1
You have to be very careful when following tutorials to follow spelling accurately. It’s very easy to miss typos in code if they don’t result in an error.
Onmove should be OnMove
If you have more questions and need to post code, you can use code tags in this forum to make it easier for people to read your code and help.
void Onmove(InputValue movementValue) needs to be void OnMove(InputValue movementValue)
Like said above you have to be exact when it comes to spelling and capitalization. Do you have the assistance turned on where it shows various colors depending on what the item you are typing is?
I fix Onmove to OnMove but still when i click play nothing happen, it won’t move.
Also wonder even when i do the wrong spelling it doesn’t show up in visual studio, not sure where to fix
Can u guys help me check where this went wrong? been stuck here for a while now
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour
{
public float speed = 0;
private Rigidbody rb;
private float movementX;
private float movementY;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
void OnMove(InputValue movementValue)
{
Vector2 movementVector = movementValue.Get<Vector2>();
movementX = movementVector.x;
movementY = movementVector.y;
}
void FixedUpdate()
{
Vector3 movement = new Vector3(movementX, 0.0f, movementY);
rb.AddForce(movement * speed);
}
}
This will come with intellisense as well which will make looking over your code much easier.
Now you should see red underline squiggles, different color on words depending on what they are. And a dropdown menu when typing out known words that can help you go faster. Pressing tab with that drop down will select the first one on the list and auto complete it.