#i created a cube called player and a
1 messages · Page 1 of 1 (latest)
in my project i created a cube called " player "
my goal is to make this cube moves hirzontaly and verticaly
iam a beginner
The name of the cube doesent really matter. If you want the script to affect the player you need to attach the player with the script
no worries I was also a beginner a few years ago
go to your cube -> on the properties pannel click add a component
then you can add your script (or drag and drop it there)
ok let me try that
ok now i added my script to the cube
run the game does it work?
wait
still the same problem : The referenced script (Unknown) on this Behaviour is missing!
could you send a picture of the cube and the components
sure
wait
after i run the project the script file that i added to the cube show an error .. i added the script file only one time i do not know how did these two files come
@somber sedge
show me a picture of it in the editor
the cube or the script file ?
this missing error only appears when you run the game or in the editor also
yes
send a picture of the cube with its properties
without running the game (so in editor)
this is the project
ok yes but show me the properties underneath the box collider,
ok click ont he 3 arrows, and remove both the scripts
where are them
paste the code of the script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class player : MonoBehaviour
{
Rigidbody rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(h, 0, v);
rb.AddForce(movement * 10);
}
}
ok remove all the scripts from the player components, create a new empty script, does it show up normally or still give you that same error
im not sure why youre getting this error
yes i deleted the script file and created a new one with the same name also " player "
it shows the same problem
at first it was not showing any errors
at first a created a script file and add this in it : Debug.Write("hello world");
and it was working
So it’s still broken? Even with an empty script?
the script has the main code .. this code :
and yes
it still broken
might i can change the file name ?
might work
such as " playerr "
instead of " player "
bro
Call it PlayerMovement
ok