mostlyhuman
Member
I have created a shared list variable called SharedAttackEvent which has several properties one of which is a float called attackProbability. In a new Task I have created a SharedAttackEvent attackEvents and in OnStart() I am trying to iterate through all of the attackEvents in the list to add the probabilities together
but I cant figure out the correct syntax to do this since its a Shared variable type list. Thank you for any help!.
Here are the definitions in case you need to see these to help:
C#:
public SharedAttackEvent attackEvents;
float weightTotal;
foreach(SharedAttackEvent attackEvent in attackEvents.Value)
{
weightTotal += attackEvent.attackProbability;
}
but I cant figure out the correct syntax to do this since its a Shared variable type list. Thank you for any help!.
Here are the definitions in case you need to see these to help:
C#:
[System.Serializable]
public class SharedAttackEvents : SharedVariable<List<AttackEvent>>
{
public static implicit operator SharedAttackEvents(List<AttackEvent> value) { return value; }
}
[System.Serializable]
public class AttackEvent
{
public string attackName;
public float attackProbability;
public float distanceNeeded;
}
Last edited: