|
Post by Chronicman on Apr 6, 2020 18:20:37 GMT
Stacking vTriggerGenericAction with different keys inputs. The vGenericAction class will only detect 1 input. I'm trying get use vTriggerGenericActions to make complex objects.
Example1: A tv that can turn on and off and change channels. Example2: A fuse box where fuses can be added and removed.
|
|
|
Post by Chronicman on Apr 6, 2020 23:27:08 GMT
I have found a work around for this can you guys foresee any problems with doing this?
public virtual void TriggerActionInput()
{
if (triggerAction == null || !triggerAction.gameObject.activeInHierarchy) return;
// if (canTriggerAction)
{
for(int i = 0; i < colliders.Count; i++)//added
{
triggerAction = colliders[i].GetComponent<vTriggerGenericAction>(); //added
if (triggerAction.inputType == vTriggerGenericAction.InputType.AutoAction && actionConditions)
{
TriggerAnimation();
}
else if (triggerAction.inputType == vTriggerGenericAction.InputType.GetButtonDown && actionConditions)
{
if (triggerAction.actionInput.GetButtonDown())
{
TriggerAnimation();
}
}
else if (triggerAction.inputType == vTriggerGenericAction.InputType.GetDoubleButton && actionConditions)
{
if (triggerAction.actionInput.GetDoubleButtonDown(triggerAction.doubleButtomTime))
TriggerAnimation();
}
else if (triggerAction.inputType == vTriggerGenericAction.InputType.GetButtonTimer)
{
if (_currentInputDelay <= 0)
{
// this mode will animate while you press the button and call the OnEndAction once you finish pressing the button
if (triggerAction.doActionWhilePressingButton)
{
var up = false;
var t = 0f;
// call the OnEndAction after the buttomTimer
if (triggerAction.actionInput.GetButtonTimer(ref t, ref up, triggerAction.buttonTimer))
{
triggerAction.OnFinishActionInput.Invoke();
ResetActionState();
ResetTriggerSettings();
}
// trigger the animation when you start pressing the action button
if (triggerAction && triggerAction.actionInput.inButtomTimer)
{
triggerAction.UpdateButtonTimer(t);
TriggerAnimation();
}
// call OnCancelActionInput if the button is released
if (up && triggerAction)
{
if (debugMode) Debug.Log("Cancel Action");
triggerAction.OnCancelActionInput.Invoke();
_currentInputDelay = triggerAction.inputDelay;
triggerAction.UpdateButtonTimer(0);
ResetActionState();
ResetTriggerSettings();
}
}
// this mode will call the animation and event only when the buttonTimer finished
else
{
if (triggerAction.actionInput.GetButtonTimer(triggerAction.buttonTimer))
{
TriggerAnimation();
if (playingAnimation)
{
if (debugMode) Debug.Log("call OnFinishInput Event");
triggerAction.OnFinishActionInput.Invoke();
}
}
}
}
else
{
_currentInputDelay -= Time.deltaTime;
}
}
}
}
}
|
|
|
Post by Chronicman on Apr 7, 2020 17:26:55 GMT
Bump
|
|
|
Post by Invector on Apr 8, 2020 14:55:12 GMT
We spend the whole day yesterday working on the GenericAction, there were some flaws when using the GetButtonTimer but now it's fixed I will take a look at your modification, did you tested on other situations like collecting items that are close together, etc...
|
|
|
Post by Chronicman on Apr 8, 2020 16:21:51 GMT
I tested it on a few things, I have set up a TV with on and off trigger, a trigger to control the channels. I set up a dresser drawer to open and close when its open you can collect an item. Every thing is working pretty well except the OnPlayerEnter Exit and Stay. These functions are having trouble firing on all triggers. All I did was add a loop in the input detection in the generic action. I did take a look at some of the other code but to be frank I got lost in it lol.
I thought of another work around last night that I'm going to try today. I'm gonna create a new script this will hopefully control a bunch of generic actions under 1 collider. This script detect input by the keys specified in the vTriggerGenericAction. If an input has been detected it will send all the required info to the vGenericAction and tell it to do its thing.
|
|
|
Post by Chronicman on Apr 8, 2020 16:40:20 GMT
We spend the whole day yesterday working on the GenericAction, there were some flaws when using the GetButtonTimer but now it's fixed I will take a look at your modification, did you tested on other situations like collecting items that are close together, etc... I did notice that the OnPlayerStay was not firing off, did you guys look into that yesterday aswell ?
|
|
|
Post by Chronicman on Apr 8, 2020 19:53:59 GMT
So I think that this script I have made has done the trick! I just got it working and haven't fully tested it but it seems promising.
|
|
|
Post by Chronicman on Apr 9, 2020 3:06:21 GMT
Don't mind my model art work lol clearly not an artist.
|
|
|
Post by xuyuepeng on Jul 2, 2021 7:02:33 GMT
Great work,I'm studying it, but I'm a little lost
Can you share it? Record a paid tutorial。
|
|