using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
public float PlayerSpeed;
public GameObject ProjectilePrefab;
// Update is called once per frame
void Update ()
{
// Amount to move
float amtToMove = Input.GetAxis("Horizontal") * PlayerSpeed * Time.deltaTime;
//Move the Player
transform.Translate(Vector3.right * amtToMove);
//ScreenWrap
if (transform.position.x <= -7.7f)
transform.position = new Vector3(7.69f, transform.position.y, transform.position.z);
else if (transform.position.x >= 7.7f)
transform.position = new Vector3(-7.69f, transform.position.y, transform.position.z);
if (Input.GetKeyDown("space"))
{
// Fire Projectile (I THINK THIS IS THE LINE THAT HAS ERROR ON LOCALSCALE)
Vector3 position = new Vector3(transform.position.x, transform.position.y + (transform.localScale / 2));
Instantiate(ProjectilePrefab, position, Quaternion.identity);
}
}
}
I GET THE FOLLOWING ERRORS
Assets/Scrips/Player.cs(27,86): error CS0019: Operator + cannot be applied to operands of type ‘float’ and ‘UnityEngine.Vector3’
Assets/Scrips/Player.cs(27,117): error CS1502: The best overloaded method match for ‘UnityEngine.Vector3.Vector3(float, float)’ has some invalid arguments
Assets/Scrips/Player.cs(27,117): error CS1503: Argument ‘#2’ cannot convert ‘object’ expression to type ‘float’