Today I wanted to finish the animation for the 2D course itself on Unity, but I got a very strange error:
Assets\Scripts\PlayerController.cs(1,30): error CS0234: The type or namespace name ‘Dataflow’ does not exist in the namespace ‘System.Threading.Tasks’ (are you missing an assembly reference?)
Please explain what needs to be done? (Here is the code itself)
using System.Threading.Tasks.Dataflow;
using System.Numerics;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
[SerializeField] private float moveSpeed = 1f;
private PlayerControls playerControls;
private UnityEngine.Vector2 movement;
private Rigidbody2D rb;
private Animator myAnimator;
private SpriteRenderer mySpriteRenderer;
private void Awake()
{
playerControls = new PlayerControls();
rb = GetComponent<Rigidbody2D>();
myAnimator = GetComponent<Animator>();
mySpriteRenderer = GetComponent<SpriteRenderer>();
}
private void OnEnable()
{
playerControls.Enable();
}
private void Update()
{
PlayerInput();
AdjustPlayerFacingDirection(); // Call the facing direction adjustment here or as needed.
}
private void FixedUpdate()
{
Move();
}
private void PlayerInput()
{
movement = playerControls.Movement.Move.ReadValue<Vector2>();
myAnimator.SetFloat("moveX", movement.x);
myAnimator.SetFloat("moveY", movement.y);
}
private void Move()
{
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
}
private void AdjustPlayerFacingDirection()
{
Vector3 mousePos = Input.mousePosition;
Vector3 playerScreenPoint = Camera.main.WorldToScreenPoint(transform.position);
if (mousePos.x < playerScreenPoint.x)
{
mySpriteRenderer.flipX = true;
}
else
{
mySpriteRenderer.flipX = false; // Use flipX to control horizontal flipping.
}
}
}