Hello all.
I have just begun to play with Unity and trying to learn by doing small, simple projects and following tutorials. However - some of the (simplest) thing I want do to seems very hard by this point. Therefore I beg you to be kind - I promise I’ll be better soon
Yesterday I begun a simple project which I need to make a gameobject move by mouse input.
I have attached the following script to the gameobject (an excerpt):
if(Input.GetAxis("Mouse X") < 0) {
transform.position.x -= playerMoveSpeed * Time.deltaTime;
//print("Moved left");
}
if(Input.GetAxis("Mouse X") > 0) {
transform.position.x += playerMoveSpeed * Time.deltaTime;
//print("Moved right");
}
if(Input.GetAxis("Mouse Y") > 0) {
transform.position.z += playerMoveSpeed * Time.deltaTime;
//print("Moved up");
}
if(Input.GetAxis("Mouse Y") < 0) {
transform.position.z -= playerMoveSpeed * Time.deltaTime;
//print("Moved down");
}
This should be simple in my mind, but the gameobject don’t follow the mouse! I can move the object right after starting the game, but the object is moving slower and slower and almost stop moving even with large mouse movements. The mouse pointer and objects is also not the same (the pointer start at Unitys “playbutton” above the gamescreen, but the object is on the bottom).
Can anybody give me a hint how to solve this, or tell me if it’s possible at all.