Hello guys, i’m new to unity and making a script by guide i stuck on issue
error CS0246: The type or namespace name ‘ReycastHit2D’ could not be found (are you missing a using directive or an assembly reference?)
(link to guide that I’m currently using)
https://www.youtube.com/watch?v=b8YUfee_pzc
Timecode is 51:00
My code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
private BoxCollider2D boxCollider;
private Vector3 moveDelta;
private ReycastHit2D hit;
private void Start()
{
boxCollider = GetComponent();
}
private void FixedUpdate()
{
float x = Input.GetAxisRaw(“Horizontal”);
float y = Input.GetAxisRaw(“Vertical”);
// Reset moveDelta
moveDelta = new Vector3(x,y,0);
// Swap sprite direction whether you’re going right or left
if (moveDelta.x > 0)
transform.localScale = Vector3.one;
else if (moveDelta.x<0)
transform.localScale = new Vector3(-1, 1, 1);
// Make sure we can move in this direction, by casting a box there first if the box returns null, we’re free to move
hit = Physics2D.Boxcast(transform.position,boxCollider.size, 0, new Vector2(0, moveDelta.y), Mathf.Abs(moveDelta.y * Time.deltaTime), LayerMask.GetMask(“Actor”,“Blocking”));
if (hit.collider == null)
{
// Make this thing move!
transform.Translate(0, moveDelta.y * Time.deltaTime, 0);
}
hit = Physics2D.Boxcast(transform.position,boxCollider.size, 0, new Vector2(moveDelta.x, 0), Mathf.Abs(moveDelta.x * Time.deltaTime), LayerMask.GetMask(“Actor”,“Blocking”));
if (hit.collider == null)
{
// Make this thing move!
transform.Translate(moveDelta.x * Time.deltaTime, 0, 0);
}
}
}
7898050–1006006–Player.cs (1.6 KB)