Im getting unity vector3 errors, but I've never mentioned that in my program. help?
using UnityEngine;
public class PlayerMovement : MonoBehaviour {
[SerializeField] public Rigidbody rb;
[SerializeField] public int speed = 10;
// Update is called once per frame
void FixedUpdate()
{
// These are the keys.
if ( Input.GetKey("a") )
{
rb.AddForce(-transform.forward*speed, 0, 0);
}
if ( Input.GetKey("d") )
{
rb.AddForce(transform.forward*speed, 0, 0);
}
if ( Input.GetKey("w") )
{
rb.AddForce(0, 0, transform.forward*speed);
}
if ( Input.GetKey("s") )
{
rb.AddForce(0, 0, -transform.forward*speed);
}
}
}
errors:
ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <437ba245d8404784b9fbab9b439ac908>:0) System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <437ba245d8404784b9fbab9b439ac908>:0) System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <437ba245d8404784b9fbab9b439ac908>:0) UnityEngine.UIElements.VisualElement+Hierarchy.get_Item (System.Int32 key) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/VisualElementHierarchy.cs:461) UnityEngine.UIElements.EventDispatchUtilities.PropagateToIMGUIContainer (UnityEngine.UIElements.VisualElement root, UnityEngine.UIElements.EventBase evt) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Events/IEventDispatchingStrategy.cs:161) UnityEngine.UIElements.MouseEventDispatch
Assets/PlayerMovement.cs(14,25): error CS1503: Argument 1: cannot convert from 'UnityEngine.Vector3' to 'float'
Assets/PlayerMovement.cs(18,25): error CS1503: Argument 1: cannot convert from 'UnityEngine.Vector3' to 'float'
Assets/PlayerMovement.cs(22,31): error CS1503: Argument 3: cannot convert from 'UnityEngine.Vector3' to 'float'
Assets/PlayerMovement.cs(26,31): error CS1503: Argument 3: cannot convert from 'UnityEngine.Vector3' to 'float'
transform.forwardis aVector3, so it is indeed used by your code - Biesi Grr