Good news! To provide faster support and grow the community, we'll be changing the forum to "Read Only" and turn to Discord instead for support.
Join here: https://discord.gg/zjNj5zZ

How to use Trigger Callbacks

User avatar
PeterBibinin
Posts: 194
Joined: Mon Oct 24, 2016 10:55 pm
Location: Poland
Contact:

Re: How to use Trigger Callbacks

Postby PeterBibinin » Wed Sep 06, 2017 11:09 pm

Look. I use this in Photon Integration.

Code: Select all

using Devdog.General;
using Devdog.InventoryPro;
using EquippablePhoton;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PhotonItemTrigger : Photon.MonoBehaviour, ITriggerCallbacks
{


    public bool OnTriggerUsed(Player generalPlayer)
    {

        DevdogLogger.LogVerbose("Player picked up item", generalPlayer);

        var player = PlayerManager.instance.currentPlayer;
        var item = GetComponent<EquippableInventoryItem>();

        player.GetComponent<EnableEquipmentPhotonLocal>().PickUpItem(item);


        return false;
    }

    public bool OnTriggerUnUsed(Player player)
    {

        return false;
    }

}


You dont return false; maybe this is your problem


//////EDIT

Yes you must add return false; This is your problem
Waiting for sunrise
-------------------------------------------
Try make world beter ;]

My Advanced Save System tutorial with screen capture like in The Forest !
Advanced Save System
-------------------------------------------
BAZINGA !

Adressa
Posts: 9
Joined: Wed Aug 30, 2017 6:55 pm

Re: How to use Trigger Callbacks

Postby Adressa » Thu Sep 07, 2017 5:00 am

Wow It works, thanks for all the help. Do you know how to not use UnUsed in this case? This is a checkpoint and I want my player to click once and the next click Uses it again, not doing UnUsed.

User avatar
PeterBibinin
Posts: 194
Joined: Mon Oct 24, 2016 10:55 pm
Location: Poland
Contact:

Re: How to use Trigger Callbacks

Postby PeterBibinin » Thu Sep 07, 2017 7:25 am

Did you try just remove unused bool ?
Waiting for sunrise
-------------------------------------------
Try make world beter ;]

My Advanced Save System tutorial with screen capture like in The Forest !
Advanced Save System
-------------------------------------------
BAZINGA !

Adressa
Posts: 9
Joined: Wed Aug 30, 2017 6:55 pm

Re: How to use Trigger Callbacks

Postby Adressa » Thu Sep 07, 2017 7:33 am

Removing UnUsed bool makes ITriggerCallbacks not work:

Code: Select all

public class RestAtWell : MonoBehaviour, ITriggerCallbacks

"RestAtWell does not implement interface member 'ITriggerCallbacks.OnTriggerUnUsed(Player)'


EDIT: If I trigger it with "Used", walk away from the object, walk in again, and trigger it again then it does "Used" again, because leaving the trigger probably has a OnTriggerExit that runs UnUsed. I'll look for that and use the same method on "Used" so it automatically does "UnUsed" when it finishes. I'll check if I can do this.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests