Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Having a problem here while trying to create an effect for enemies to fall over after death, the Unity error says:

CS1061 'Transform' does not contain a definition for 'LocalEulerAngles' and no accessible extension method 'LocalEulerAngles' accepting a first argument of type 'Transform' could be found (Are you missing a using directive or an assembly reference?)

Here is a piece of my code under,

C#
public class ShootingEnemy : Enemy

  protected override void OnKill ()  {
        base.OnKill ();

        agent.enabled = false;
        this.enabled = false;
        transform.LocalEulerAngles = new Vector3 (10, transform.LocalEulerAngles.y, transform.LocalEulerAngles.z);




Which is connected to my Enemy script




C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy : MonoBehaviour
{

    public int health = 50;
    public int damage = 5;


    void OnTriggerEnter (Collider otherCollider) {
        if (otherCollider.GetComponent<bullet>() != null) {
            Bullet bullet = otherCollider.GetComponent<bullet> ();
            if (bullet.ShotByPlayer == true) {
            health -= bullet.damage;
            bullet.gameObject.SetActive (false); 

            if (health <= 0) {
                OnKill ();
                 }
            }
        }
    }

    protected virtual void OnKill () {  }
    
}


I am not very familiar with LocalEulerAngles and am pretty new to programming so I can't pin point the problem. If you need more of my ShootingEnemy : Enemy script let me know and if you know what the problem is that would be much appreciated.


Unity error message states it on this line with all three LocalEulerAngles

C#
transform.LocalEulerAngles = new Vector3 (10, transform.LocalEulerAngles.y, transform.LocalEulerAngles.z);


What I have tried:

I have looked for fixes for CS1061 error but none have helped with my situation.
Posted
Updated 12-Jan-21 8:06am
v2

1 solution

You should follow the example.

Unity - Scripting API: Transform.localEulerAngles[^]
 
Share this answer
 
Comments
Blake Burnell 12-Jan-21 21:29pm    
just realized how retarded I am lol. The l in local isn't supposed to be capitalized... Thanks for the help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900