Getting a error with Quaternion.Euler

Hello I am getting a "Cannot implictly convert type ‘UnityEngine.Quaternion’ to ‘UnityEngine.Vector3’ Error

Here is my code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerControls : MonoBehaviour
{
    [SerializeField] float controlSpeed = 10f;
    [SerializeField] float XRange = 10f;
    [SerializeField] float YRange = 10f;
    
    void Start()
    {
        
    }

    
    void Update()
    {
        ProcessTranslation();
        ProcessRotation();
    }

    void ProcessTranslation()
    {
        float xThrow =  Input.GetAxis("Horizontal");
        float yThrow = Input.GetAxis("Vertical");
        float xOffset = xThrow * Time.deltaTime * controlSpeed;
        float yOffest = yThrow * Time.deltaTime * controlSpeed;
        float rawXpos = transform.localPosition.x + xOffset;
        float rawYpos = transform.localPosition.y + yOffest;
        float clampedXpos = Mathf.Clamp(rawXpos, -XRange, XRange);
        float clampedYpos = Mathf.Clamp(rawYpos, -YRange, YRange);

        transform.localPosition = new Vector3 (clampedXpos, clampedYpos, transform.localPosition.z);

    }

    void ProcessRotation()
    {
        transform.localPosition = Quaternion.Euler(-30f,30f,0f);
    }
}

I cannot seem to find where the error is coming from.

1 Like

Hi,

Check your ProcessRotation method carefully. What is the name of the Unity property whose value is supposed to get overridden? Remember you can also look at the lecture code changes via the link in the Resources of each lecture.

Did this help?


See also:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms