Question by
Fox_GAMING · May 16, 2018 at 01:03 AM ·
animationunityeditor
PLEASE HELP!! I'm trying to write an animation code
Here is the code, it is depreciated:
And here is my script:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class InteractiveObject : MonoBehaviour { public enum eInteractiveState { Active, //OPen Inactive, //CLose }
private eInteractiveState m_state;
void Start()
{
m_state = eInteractiveState.Inactive;
}
public void TrigegrInteraction()
{
if (!GetComponent<animation.isPlaying>)
Debug.Log("Interactive Object");
switch (m_state)
{
case eInteractiveState.Active:
animation.Play("Close");
case eInteractiveState.Inactive;
break;
case eInteractiveState.Inactive:
animation.Play("Open");
case eInteractiveState.Active;
break;
default:
break;
}
}
}
Also, I'm using Unity 2018.1.0f2. Please help me figure out what I need to substitute to get this to work.
It's also the same with this one:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class InputHandler : MonoBehaviour { void Update() {
if (Input.GetMouseButton(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity))
{
InteractiveObject obj = hit.collider.GetComponent<InteractiveObject>();
if (obj)
{
obj.TrigegrInteraction();
}
}
}
}
}
scriptyouttubeunityhelpuser.png
(243.5 kB)
scriptyouttubeunityhelpuser2.png
(205.9 kB)
Comment