Tip:
Highlight text to annotate it
X
write simple code to move player. in player add script PlayerController
script is under asset folder
double click to open it
public variable to the player
change value in inspector
it's here
class boundary is different class with playercontroller. we use system.serializable
to combine them. how do it ? public variable boundary in lowercase
to class playercontroller and refer to class Boundary in uppercase
void fixedupdate for movement. use input horizontal and vertical to make player to move in vector X
and the vector Z, no movement in Y player add rigidbody to move with speed
we write code mathf.clamp to limit player position in a boundary
we will make a boundary in xmax xmin zmax zmin. set up the boundary
change player position to test
zmin -4 zmax 13
xmin -6
xmax 6
we give player speed 10. Test.
input WSAD to control player to move