Secret Door Interactable
Allows you to interact with secret doors, but in fact, it’s much more then that. I use simillar systems to interact with torches and candles, secret doors and cracks on the walls and floor.
For context, in my example, i want a crack in the wall that if you have the ability (slash), it will allow you to transform into a secret door. This should play a sound, change sprite (in my case animation) and enable teleport, plus changes the flag in your save.
I’ll be posting in the comments too, because its too long.
Actions States - All action states that allows you to manage you operations based on the result of the interaction
Assets/Mythril2D/Core/Runtime/Scripts/Utils/EObjectAction.cs
using System;
namespace Gyvr.Mythril2D
{
[Serializable]
public enum EObjectAction
{
Switch,
Activate,
Deactivate
}
}
Object Interation Command - To call custom operations in your objects when interact with.
If you extend this class, it will allow you to perform action has a interactable.
Assets/Mythril2D/Core/Runtime/Scripts/Commands/ObjectInteration.cs
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Gyvr.Mythril2D
{
// Interface for light-specific behavior
public interface IObjectAction
{
void SetState(EObjectAction state);
}
[Serializable]
public class ObjectInteration : ICommand
{
[SerializeField] private GameObject m_object_action;
[SerializeField] private EObjectAction m_action = EObjectAction.Switch;
//Executes the custom function of the target object class that contains "IObjectAction" interface
public void Execute()
{
IObjectAction actionObject = m_object_action.GetComponent<IObjectAction>();
Debug.Assert(actionObject != null);
actionObject.SetState(m_action);
}
}
}

š¬ Comments (2)
Want to continue the conversation?