please help, i'm currently working on a brick breaker game and working on paddle script but it shows error on line 17, i don't know how to change float to vector3
using UnityEngine;
using System.Collections;
public class Paddle : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Vector3 paddlePos = new Vector3 (0.5f, this.transform.position.y, 0f);
float mousePosInBlocks = Input.mousePosition / Screen.width * 16;
paddlePos.x = Mathf.Clamp(mousePosInBlocks, 0.5f, 15.5f);
this.transform.position = paddlePos;
}
}
here is the script combined both answers
public class Paddle : MonoBehaviour {
Vector3 mousePosInBlocks;
Vector3 paddlePos;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
paddlePos = new Vector3 (0.5f, this.transform.position.y, 0f);
mousePosInBlocks = Input.mousePosition / Screen.width * 16;
paddlePos.x = Mathf.Clamp(mousePosInBlocks.x, 0.5f, 15.5f);
this.transform.position = paddlePos;
}
}