[Need help] - Basic movement (Camera direction)

Hello! im new in unity and I don’t have a lot of skills in coding, I am trying to make a simple movement systeme for my “player” which is a cube, I can make it move nicely in each direction perfectly. here’s the script im using at this moment:

using UnityEngine;
using System.Collections;

public class playerMovement : MonoBehaviour {
    public float moveSpeed;
    private float maxSpeed = 5f;
    public GameObject deathParticles;
    private Vector3 spawn;
    private Vector3 input;

    // Use this for initialization
    void Start () {
        spawn = transform.position;
    }
   
    // Update is called once per frame
    void Update () {
        input = new Vector3 (Input.GetAxis ("Horizontal"), 0, Input.GetAxis ("Vertical"));
        if (rigidbody.velocity.magnitude < maxSpeed)
        {
            rigidbody.AddRelativeForce (input * moveSpeed);
        }
        if(transform.position.y < -5)
        {
            Die ();
        }
    }

    void OnCollisionEnter(Collision other)
    {
        if(other.transform.tag == "Enemy")
        {
            Die();
        }
    }
    void OnTriggerEnter(Collider other)
    {
        if(other.transform.tag == "Goal")
        {
            GameManager.CompleteLevel();
        }
    }

    void Die()
    {
        Instantiate(deathParticles, transform.position, Quaternion.identity);
        transform.position = spawn;
    }
}

I have a mouse orbit camera attached to it and I would like to know how to push my cube in the direction my mouse is pointing instead of only going in one the direction the block is facing.

Hope it’s not too complicated :stuck_out_tongue:
Thanks

Afternoon Rahas.

Just to give my tuppence worth to get you started, im a beginner myself, but i did have to use this before.

have a look at ScreenToWorldPoint ()

it can take your current mouse position x and y, and translate that into world space coordinates.
then you can use that to move your player towards that vector value.

or use the LookAt() function on your player, and use the move keys from that.
http://unity3d.com/learn/tutorials/modules/beginner/scripting/look-at
or add your force using that vector .

hope it helps a wee bit.

the LookAt() function doesnt because it make my cube rotate to face the camera, even if I freezed the rotation. Thr ScreenToWorldPoint seems interesting, but I have no idea how to use it… Can someone tell me how please?

use the search on here…or try the scripting reference