Good evening, I have a small problem in getting my player's shot correctly directed to the left and right (the problem is on the left).
The error I get is this:"The type or namespace name 'Player' could not be found (are you missing a using directive or an assembly reference?)".
Can anyone help me?
Bullet script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bullet : MonoBehaviour
{
public float bulletSpeed;
Rigidbody2D rb;
// Update is called once per frame
void Start()
{
rb = GetComponent<Rigidbody2D>();
Transform playerTransform = FindObjectOfType<Player>().transform;
rb.velocity = transform.right * playerTransform.localScale.x * bulletSpeed;
}
}
PlayerAttack script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAttack : MonoBehaviour
{
public Transform spawnPos;
public GameObject bullet;
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Instantiate(bullet, spawnPos.position, spawnPos.rotation);
}
}
}