playMaker

Author Topic: Cant Find a Property with "Set Property"  (Read 1818 times)

shadowof047

  • Playmaker Newbie
  • *
  • Posts: 15
    • View Profile
Cant Find a Property with "Set Property"
« on: April 25, 2016, 12:18:08 AM »
Hello .
At first i wanna say that i searched the forum for this and found some other topics such as this :

http://hutonggames.com/playmakerforum/index.php?topic=4898.0

but i couldnt find my answer there . so here is my question :

I have this script :

Code: [Select]
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using Invector;

public class MeleeWeapon : MeleeItem
{
    #region variables
    [Header("Weapon Settings")]
    public int ATK_ID;
    public int MoveSet_ID;
   
    public Damage damage;
    public DamagePercentage damagePercentage;

    [Tooltip("How much stamina the attack will consume")]
    public float staminaCost = 30f;
    [Tooltip("Time for the stamina to recover")]
    public float staminaRecoveryDelay = 1f;

    [Header("Hitbox Settings")]
    [Range(0.1f, 2.9f)]
    public float centerSize = 1f;
    [Range(-1.4f, 1.4f)]
    public float centerPos = 0f;
    public BoxCollider top, bottom, center;
    public bool showHitboxes;
    public HitProperties hitProperties { get; set; }
    protected float curCenterSize;
    [HideInInspector]
    public HitBox hitTop, hitBotton, hitCenter;
    public bool lockHitBox = true;           
    #endregion


    [System.Serializable]
    public class DamagePercentage
    {
public float Top = 30f;
        public float Center = 70f;       
    }

    public void Init()
    {
        hitTop = top.GetComponent<HitBox>();
        hitBotton = bottom.GetComponent<HitBox>();
        hitCenter = center.GetComponent<HitBox>();

        hitTop.hitBarPoint = HitBarPoints.Top;
        hitCenter.hitBarPoint = HitBarPoints.Center;
        hitBotton.hitBarPoint = HitBarPoints.Bottom;

        hitTop.hitControl = this;
        hitBotton.hitControl = this;
        hitCenter.hitControl = this;

    }   

    public bool isActive { get { return active; } }

    public struct DamageType
    {
        public Collider hitCollider;
        public HitBarPoints hitBarPoints;
    }
}

I want to access the float "Top " and float "Center" in the Class "DamagePercentage" , but they are nowhere to be found .

Also when i add this script some other variables shows up in the inspector such as float "Value" or bool "Ignore Defense " which are not even in the script ( and i'm too noob to know where it is reading them from )

It maybe worth mentioning that it is "Melee Weapon" Script from " Melee Combat Template " asset by Invector .

Can someone help me on this ?



shadowof047

  • Playmaker Newbie
  • *
  • Posts: 15
    • View Profile
Re: Cant Find a Property with "Set Property"
« Reply #1 on: April 25, 2016, 05:46:16 AM »
After doing some more search i found this topic on the forum which had a similar problem like me :

http://hutonggames.com/playmakerforum/index.php?topic=10222.0

After reading through it , i found that the variables i'm trying to access is from Damage class . but i cant quite find a way to solve my problem , here is the line which declares a damage class in first script :

Code: [Select]
public Damage damage;
and here is the actual damage class in second script :

Code: [Select]
public class Damage
{
    [Tooltip("Apply damage to the Character Health")]
    public int value;
    [Tooltip("Apply damage even if the Character is blocking")]
    public bool ignoreDefense;
    [Tooltip("Activated Ragdoll when hit the Character")]
    public bool activeRagdoll;
    [HideInInspector] public Transform sender;
    [HideInInspector] public Recoil_ID recoil_id;

    public Damage (int value, bool ignoreDefense, bool activeRagdoll, Transform sender, Recoil_ID recoil_ID)
    {
        this.value = value;
        this.ignoreDefense = ignoreDefense;
        this.activeRagdoll = activeRagdoll;
        this.sender = sender;
        this.recoil_id = recoil_ID;
    }

    public enum Recoil_ID
    {
        low,
        medium,
        hard
    }

    public Damage(Damage damage)
    {
        this.value = damage.value;
        this.ignoreDefense = damage.ignoreDefense;
        this.activeRagdoll = damage.activeRagdoll;
        this.sender = damage.sender;
        this.recoil_id = damage.recoil_id;
    }
}

So how should i modify the first script to access "Value" variable in Damage class ? thanks.

mdotstrange

  • Hero Member
  • *****
  • Posts: 549
    • View Profile
    • Can't code? Who cares! Make games anyway!
Re: Cant Find a Property with "Set Property"
« Reply #2 on: April 25, 2016, 06:16:24 AM »
If you can't access what you want in a script via get/set property or the method actions included with PM in the ScriptControl section you'll need a custom action-

I'm just an amateur coder but if you post the scripts I can have a go at making an action for it when I get the chance-
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

shadowof047

  • Playmaker Newbie
  • *
  • Posts: 15
    • View Profile
Re: Cant Find a Property with "Set Property"
« Reply #3 on: April 25, 2016, 08:30:36 PM »
If you can't access what you want in a script via get/set property or the method actions included with PM in the ScriptControl section you'll need a custom action-

I'm just an amateur coder but if you post the scripts I can have a go at making an action for it when I get the chance-

That would be greatly appreciated because i'm really stuck  :-[

Here is the complete first script which is called "MeleeWeapon.cs" :

Code: [Select]
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using Invector;

public class MeleeWeapon : MeleeItem
{
    #region variables
    [Header("Weapon Settings")]
    public int ATK_ID;
    public int MoveSet_ID;
   
public Damage damage;
    public DamagePercentage damagePercentage;

    [Tooltip("How much stamina the attack will consume")]
    public float staminaCost = 30f;
    [Tooltip("Time for the stamina to recover")]
    public float staminaRecoveryDelay = 1f;

    [Header("Hitbox Settings")]
    [Range(0.1f, 2.9f)]
    public float centerSize = 1f;
    [Range(-1.4f, 1.4f)]
    public float centerPos = 0f;
    public BoxCollider top, bottom, center;
    public bool showHitboxes;
    public HitProperties hitProperties { get; set; }
    protected float curCenterSize;
    [HideInInspector]
    public HitBox hitTop, hitBotton, hitCenter;
    public bool lockHitBox = true;           
    #endregion


    [System.Serializable]
    public class DamagePercentage
    {
public float Top = 30f;
        public float Center = 70f;       
    }

    //public override Type GetSubType()
    //{
    //    return GetType();
    //}
    public void Init()
    {
        hitTop = top.GetComponent<HitBox>();
        hitBotton = bottom.GetComponent<HitBox>();
        hitCenter = center.GetComponent<HitBox>();

        hitTop.hitBarPoint = HitBarPoints.Top;
        hitCenter.hitBarPoint = HitBarPoints.Center;
        hitBotton.hitBarPoint = HitBarPoints.Bottom;

        hitTop.hitControl = this;
        hitBotton.hitControl = this;
        hitCenter.hitControl = this;

        #region Set ignore collision for all hitBox
        //if (transform.GetComponentInParent<MeleeEquipmentManager>() != null)
        //{
        //    Physics.IgnoreCollision(top, bottom);
        //    Physics.IgnoreCollision(bottom, center);
        //    Physics.IgnoreCollision(center, top);
        //    var meleeManager = transform.GetComponentInParent<MeleeEquipmentManager>();
        //    if(meleeManager==null)
        //    {
        //        Debug.LogWarning("The " + gameObject.name + " don't have a MeleeEquipmentManager");
        //    }
        //    var col = meleeManager.GetComponent<Collider>();

        //    if (col != null && col.enabled)
        //    {             
        //        Physics.IgnoreCollision(col, bottom);
        //        Physics.IgnoreCollision(col, center);
        //        Physics.IgnoreCollision(col, top);

        //        var colChild = meleeManager.GetComponentsInChildren<Collider>();
        //        foreach (Collider _col in colChild)
        //        {
        //            if (!_col.Equals(bottom) &&
        //                !_col.Equals(center) &&
        //                !_col.Equals(top) && _col.enabled)
        //            {
        //                Physics.IgnoreCollision(_col, bottom);
        //                Physics.IgnoreCollision(_col, center);
        //                Physics.IgnoreCollision(_col, top);
        //            }
        //        }
        //    }
        //}
        #endregion
    }   

    public bool isActive { get { return active; } }

    public struct DamageType
    {
        public Collider hitCollider;
        public HitBarPoints hitBarPoints;
    }
}

and here is the second script which is called "vObjectDamage" :

Code: [Select]
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class vObjectDamage : MonoBehaviour
{   
    public Damage damage;   
    [Tooltip("List of tags that can be hit")]
    public List<string> tags;   
    public bool useTrigger, useCollision;

void OnCollisionEnter(Collision hit)
{
        if (!useCollision)
            return;
if(tags.Contains(hit.transform.tag))
{
            damage.sender = transform;
            // apply damage to Character           
            hit.transform.SendMessage ("TakeDamage", damage, SendMessageOptions.DontRequireReceiver);
}
}

    void OnTriggerEnter(Collider hit)
    {
        if (!useTrigger)
            return;
        if (tags.Contains(hit.transform.tag))
        {
            damage.sender = transform;
            // apply damage to Character
            hit.transform.SendMessage("TakeDamage", damage, SendMessageOptions.DontRequireReceiver);           
        }
    }
}

[System.Serializable]
public class Damage
{
    [Tooltip("Apply damage to the Character Health")]
    public int value;
    [Tooltip("Apply damage even if the Character is blocking")]
    public bool ignoreDefense;
    [Tooltip("Activated Ragdoll when hit the Character")]
    public bool activeRagdoll;
    [HideInInspector] public Transform sender;
    [HideInInspector] public Recoil_ID recoil_id;

    public Damage (int value, bool ignoreDefense, bool activeRagdoll, Transform sender, Recoil_ID recoil_ID)
    {
        this.value = value;
        this.ignoreDefense = ignoreDefense;
        this.activeRagdoll = activeRagdoll;
        this.sender = sender;
        this.recoil_id = recoil_ID;
    }

    public enum Recoil_ID
    {
        low,
        medium,
        hard
    }

    public Damage(Damage damage)
    {
        this.value = damage.value;
        this.ignoreDefense = damage.ignoreDefense;
        this.activeRagdoll = damage.activeRagdoll;
        this.sender = damage.sender;
        this.recoil_id = damage.recoil_id;
    }
}
« Last Edit: April 25, 2016, 08:38:10 PM by shadowof047 »

mdotstrange

  • Hero Member
  • *****
  • Posts: 549
    • View Profile
    • Can't code? Who cares! Make games anyway!
Re: Cant Find a Property with "Set Property"
« Reply #4 on: April 26, 2016, 02:20:19 AM »
Ok what variables do you want to access?

Do you want to set them from a Playmaker action or get them?
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

shadowof047

  • Playmaker Newbie
  • *
  • Posts: 15
    • View Profile
Re: Cant Find a Property with "Set Property"
« Reply #5 on: April 26, 2016, 07:12:53 AM »
Ok what variables do you want to access?

Do you want to set them from a Playmaker action or get them?

i want to Set the "value" and "ignoreDefense" variables with playmaker action .
Thank you very much

mdotstrange

  • Hero Member
  • *****
  • Posts: 549
    • View Profile
    • Can't code? Who cares! Make games anyway!
Re: Cant Find a Property with "Set Property"
« Reply #6 on: April 26, 2016, 02:11:11 PM »
Where is that vObjectDamage script used? Is it attached to the Playable character or NPC? I attached an action- I don't have the asset so I can't test it- but if the script is on the object with this FSM it will set it-
« Last Edit: April 26, 2016, 02:46:46 PM by mdotstrange »
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

mdotstrange

  • Hero Member
  • *****
  • Posts: 549
    • View Profile
    • Can't code? Who cares! Make games anyway!
Re: Cant Find a Property with "Set Property"
« Reply #7 on: April 26, 2016, 02:55:15 PM »
I went ahead and made an action that sets all the vars on the vObjectDamage script- it is attached-
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

shadowof047

  • Playmaker Newbie
  • *
  • Posts: 15
    • View Profile
Re: Cant Find a Property with "Set Property"
« Reply #8 on: April 26, 2016, 11:19:00 PM »
Where is that vObjectDamage script used? Is it attached to the Playable character or NPC? I attached an action- I don't have the asset so I can't test it- but if the script is on the object with this FSM it will set it-

"vObjectDamage" script is not even in the scene , there is a line in "MeleeWeapon" script :

Code: [Select]
public Damage damage;

this Damage class is declared in "vObjectDamage"  , but only "MeleeWeapon" script exists in the scene .

I just tested the actions that you kindly wrote , it isays "Gameobject requires a vObjectDamage Component"  , but that script is not attached to my game object ( in this case , the player)
« Last Edit: April 26, 2016, 11:26:08 PM by shadowof047 »

mdotstrange

  • Hero Member
  • *****
  • Posts: 549
    • View Profile
    • Can't code? Who cares! Make games anyway!
Re: Cant Find a Property with "Set Property"
« Reply #9 on: April 27, 2016, 01:56:46 AM »
I see- since I don't have the asset I can't test/debug it properly- sorry about that- If I have the time I will go back and see if I can fix it
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

shadowof047

  • Playmaker Newbie
  • *
  • Posts: 15
    • View Profile
Re: Cant Find a Property with "Set Property"
« Reply #10 on: April 27, 2016, 04:15:29 AM »
it is very kind of you to even try  , and i appreciate it .
Since it a paid asset , i'm not sure what the rules are about putting it's script here  :'(

mdotstrange

  • Hero Member
  • *****
  • Posts: 549
    • View Profile
    • Can't code? Who cares! Make games anyway!
Re: Cant Find a Property with "Set Property"
« Reply #11 on: April 27, 2016, 04:48:43 AM »
In order for the action to work you need to set variables on a script that is not on a gameobject or in the scene- I've never done that before as I always use GetComponent and grab the script-

I'll give it another try this week as I'd like to learn how to do it-

If anyone reading can drop me a hint that would be great  :)
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: Cant Find a Property with "Set Property"
« Reply #12 on: April 28, 2016, 01:42:13 AM »
Hi,

 the best way for this would be to create a custom action really.

 Have you contacted the author and mention you'd make good use of some PlayMaker support for that asset?

Bye,

 Jean

shadowof047

  • Playmaker Newbie
  • *
  • Posts: 15
    • View Profile
Re: Cant Find a Property with "Set Property"
« Reply #13 on: May 01, 2016, 04:07:48 AM »
Hi .
Thanks " mdotstrange " for all the support you have given .

Thats a good idea Jean , i'm gonna try it since it is the best 3rd controller there is ( in my idea ) and many would benefit from the integration of playmaker in it, including the developer .