|
Post by Legend on Jul 19, 2018 19:08:29 GMT
yeeeesh i figured it out for the real fx thing - gonna be weird cause everything i have done so far is basically just moving position and rotating etc - now i am putting a box collider on to the dudes so that when the projectile hits it will do the collision portion then i can do a collision event( i assume havent looked at this yet) that will play a animation clip that will show the sprite being hit or something
also have to figure out how to go through and disable all these box coliders so that i only enable the one for that target so that it doesnt hit other targets in the way...here goooeesss
====== using the prefab effect method
var rotation = Quaternion.LookRotation(target.position - source.position);
var projectile = Instantiate(testProjectile, source.position, rotation); projectiles.Add(projectile);
|
|
|
Post by Legend on Jul 23, 2018 15:41:51 GMT
singleton prefab manager
which u can use to just load prefabs
modified projectiles:
projectiles = DoProjectile((damageaction.source as Ability).card,CVsource.transform, damageaction.targets);
and
var projectile = Instantiate(PrefabManager.Instance.GetPrefabByID(sourceCard.id), source.position, rotation);
prefab manager
public List<GOPrefab> PrefabRepository;
private readonly Dictionary<string, GOPrefab> _indexedRepository = new Dictionary<string, GOPrefab>(); public GameObject defaultPrefab;
public enum PrefabTypes { VFX, Misc }
public void Start() { foreach (var eachPrefab in PrefabRepository) _indexedRepository[eachPrefab.id] = eachPrefab; }
public GameObject GetPrefabByID(string id, PrefabTypes expectedType = PrefabTypes.Misc) { GOPrefab output; if (_indexedRepository.TryGetValue(id, out output)) { if (expectedType != PrefabTypes.Misc && output.type != expectedType) // For now, just a warning Debug.LogWarning("Prefab: " + id + " does not match expected type: " + expectedType); return output.prefab; } return defaultPrefab; }
with another class:
[Serializable] public class GOPrefab { public string id; public GameObject prefab; public PrefabManager.PrefabTypes type; }
hope that helps anyone
|
|
|
Post by Legend on Jul 23, 2018 15:56:51 GMT
whoops - should have been damageaction.source as Card)
|
|
|
Post by Legend on Jul 25, 2018 17:51:28 GMT
I have been working for this on hours - does anyone know how to play a particle system DURING an animation
for instance i attached a physicalhitfx prefab to object getting hit - then i have this code to enable it while (Time.time < continue_time) { if(bfcvD.PhysicalHitFX.activeself == false) bfcvD.PhysicalHitFX.SetActive(true); yield return false; }
basically it plays the attack clip of the sprite during the while loop so within that it should enable and play the effect right away what it does is it waits completely for the attack sequence to finish - attacker goes back to the original position etc and then actually plays the effect.
Anyone have any suggestions on this one ? thanks!
|
|
|
Post by Admin on Jul 26, 2018 13:24:00 GMT
Where is the code located that you took the snippet from? If it is on the same object, and the object is not active, then it may not be running your code at all. Have you verified that the code inside the while loop is being triggered (such as by a breakpoint or a Debug.Log statement)?
Assuming that the code is being triggered, and the particle object is becoming active, are you also doing something to make sure to "Play" the particle system?
|
|
|
Post by Legend on Jul 26, 2018 14:40:46 GMT
i used the debug. statement to make sure it did run the code which it does output - also when i remove the code it doesnt play the system through at all...further it automatically plays when i enable it so i just active to true - i also try play...
also also i tried swapping to a different method - animation and it also is having issues - it waits to complete the whole thing then it executes the actual animation too
IEnumerator OnPerformAttack(IContainer game, GameAction action) { float continue_time = 0f; var attackAction = action as AttackAction; var board = GetComponent<BoardView>(); var attacker = board.GetMatch(attackAction.attacker); var target = board.GetMatch(attackAction.target); if (attacker == null || target == null) yield break; var startPos = attacker.transform.position; var toTarget = target.transform.position - startPos;
bool pause_for_attack = false;
BattlefieldCardView bfcv = attacker.GetComponentInChildren<BattlefieldCardView>(); BattlefieldCardView bfcvD = target.GetComponentInChildren<BattlefieldCardView>();
//disable stats for attack bfcv.statsCanvas.SetActive(false); bfcvD.statsCanvas.SetActive(false); //
Animator anim = bfcv.gameObject.GetComponentInChildren<Animator>() ?? null;
Vector3 attackOffset;
if (game.GetMatch().CurrentPlayer.mode == ControlModes.Local) attackOffset = new Vector3(-.65f, 0, 0); else attackOffset = new Vector3(.65f, 0, 0);
bfcv?.PlayMinionClip(EMinionState.Jump); var tweener = attacker.transform.JumpTo(target.transform.position + attackOffset, 2, .5f);
while (tweener != null) yield return false;
//i just through this in here for testing for now ------ this is the portion which runs after the it jumps back tweener = target.transform.Wait(5f); while (tweener != null) { if (bfcvD.PhysicalHitFX.activeSelf == false) bfcvD.PhysicalHitFX.SetActive(true); bfcvD.PhysicalHitFX.GetComponentInChildren<Animator>().Play("PhysicalHit2", 0, 0);
yield return false; } ///////// if (bfcv) pause_for_attack = bfcv.PlayMinionClip(EMinionState.Attack); if (pause_for_attack) { continue_time = Time.time + anim.GetCurrentAnimatorClipInfo(0).Length; while (Time.time < continue_time) yield return false;
} bfcv?.PlayMinionClip(EMinionState.Jump);
tweener = attacker.transform.JumpTo(startPos + Vector3.zero, 2, .5f);
while (tweener != null) yield return false;
bfcv?.PlayMinionClip(EMinionState.Idle);
//reenable stats for attack bfcv.statsCanvas.SetActive(true); bfcvD.statsCanvas.SetActive(true); // }
basically this is what it does properly source jumps to target source attacks source jumps back to original poosition
The issue
after all that when it is done THEN it plays the hitFX
|
|
|
Post by Admin on Jul 26, 2018 19:21:38 GMT
From the code you've provided, I don't see why the particles wouldn't begin playing during the 5 second wait, of course I don't know what all is happening in your animation controller and overall game object configuration. It does seem a little weird to play the animator at every frame (just once is all that should be needed) but I don't think that is the problem. Perhaps your issue is external to this? Is it possible you are actually playing the particle based on some sort of completion event?
Does the canvas (enabled at the end) have to be active in order to see the particles?
|
|
|
Post by Legend on Jul 26, 2018 19:33:59 GMT
omg yeesh thats it... its gotta be that i put that damn GO in the canvas... so definetely would - i moved it out of that canvas...thats gotta bee it thanks!
|
|
|
Post by Legend on Jul 26, 2018 19:42:00 GMT
yup hahaha man thanks - that fixed it! - when something doesnt make sense i should default to placement and options of gameobjects in the editor.
|
|
|
Post by Admin on Jul 30, 2018 14:08:47 GMT
Awesome, glad you got it working!
|
|
|
Post by SALARD on Dec 11, 2018 21:36:42 GMT
Hi I am trying to add this sequential damage action I pretty much copied the jul 18 post and created a sequentialdamageaction and that system and added it to deckfactory but cant get it to work
i get a null reference error on the DODamageAction -
var cards = selector.SelectTargets(container); which is called from the OnPerformSequentialDamageAction at DoDamageAction(action.source, action.amount);
public class SequentialDamageAction : GameAction, IAbilityLoader { public List<IDestructable> targets; public int amount; public Container source; public int count;
#region Constructors
#region IAbility public void Load(IContainer game, Ability ability) {
var targetSelector = ability.GetAspect<ITargetSelector>(); var cards = targetSelector.SelectTargets(game); targets = new List<IDestructable>();
foreach (Card card in cards) { var destructable = card as IDestructable; if (destructable != null) targets.Add(destructable); } amount = Convert.ToInt32(ability.userInfo); count = Convert.ToInt32(ability.duration); source = ability.card; } #endregion
}
i am unsure where to look or how to troubleshoot what is giving the null reference here - there a way to debug log this?
|
|
|
Post by Admin on Dec 12, 2018 14:24:06 GMT
Yep, you can definitely add some Debug log statements. The null reference error should tell you the script and line number of the problem. Just look where it says, and add debug lines just before it. For example if the problem appears on the line DoDamageAction(action.source, action.amount) Then I would make sure action was not null, and then that the action's source was not null, etc.
|
|
|
Post by SALARD on Dec 12, 2018 16:02:34 GMT
thanks admin the hard part is the null refernce is on this line var cards = selector.SelectTargets(container); selector is = source.GetAspect<ITargetSelector>(); and im not sure how to debug a selector ( the aspect of the source container which should be the card cause in sequentialdamageaction i have : source = ability.card; which assigned source the ability.card is there a way to list out that selector's something or other? - properties? AND the containers properties - for instance if its a ability.card - how do i get it to list out the card's name in debug.log if i wanted to? would i getaspect of <Card>
|
|
|
Post by SALARD on Dec 12, 2018 17:03:37 GMT
HAHA I didnt mean to make a sad face it was the parenthesis
|
|
|
Post by SALARD on Dec 12, 2018 18:18:22 GMT
ok i figured it out - not sure what ARGO ended up doing but - i passed over the ability as a container instead of the card as a container - the itargetselector belongs to the ability not the card so not sure how that worked for him....in any case now ill see if i can get this working with that projectile system
hope this helps someone else stumbling on this!
|
|