A couple of DOTween action tasks added.

NodeCanvas Forums Custom Nodes & Tasks A couple of DOTween action tasks added.

This topic contains 1 reply, has 2 voices, and was last updated by  Gavalakis 2 months, 2 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #12415

    cugel
    Participant

    Just bought Node Canvas and having a ton of fun using it. I’m using the DOTween unity extension downloaded from this site. I added a couple of tasks to support Light color and Camera shake, thought I would share them.

    Using DOTween V2 free version.

    Light Color

    using DG.Tweening;
    using NodeCanvas.Framework;
    using ParadoxNotion.Design;
    using UnityEngine;
    
    namespace NodeCanvas.Tasks.Actions{
    
    	[Category("Tween")]
    	[Icon("DOTTween", true)]
    	public class TweenLightColor : ActionTask<Light> {
    
    		public BBParameter<Color>   color;
    		public BBParameter<float>   delay = 0f;
    		public BBParameter<float>   duration = 0.5f;
    		public Ease                 easeType = Ease.Linear;
    		public bool                 waitActionFinish = true;
    
    		private string id;
    
    		protected override void OnExecute() {
    			var tween = agent.DOColor(color.value, duration.value);
    			tween.SetDelay(delay.value);
    			tween.SetEase(easeType);
    			id = System.Guid.NewGuid().ToString();
    			tween.SetId(id);
    
    			if (!waitActionFinish) EndAction();
    		}	
    
    		protected override void OnUpdate() {
    			if (elapsedTime >= duration.value + delay.value){
    				EndAction();
    			}
    		}
    
    		protected override void OnStop(){
    			if (waitActionFinish){
    				DG.Tweening.DOTween.Kill(id);
    			}
    		}
    
    	}
    }

    Camera Shake Position

    using DG.Tweening;
    using NodeCanvas.Framework;
    using ParadoxNotion.Design;
    using UnityEngine;
    
    namespace NodeCanvas.Tasks.Actions{
    
    	[Category("Tween")]
    	[Icon("DOTTween", true)]
    	public class TweenCameraShake : ActionTask<Camera> {
    
    		public BBParameter<float>   duration;
    		public BBParameter<float>   strength = 3f;
    		public BBParameter<int>   	vibrato = 10;
    		public BBParameter<float>   randomness = 90f;
    		public BBParameter<bool>   	fadeout = true;
    		public BBParameter<float>   delay = 0f;
    		public Ease                 easeType = Ease.Linear;
    		public bool                 waitActionFinish = true;
    
    		private string id;
    
    		protected override void OnExecute() {
    
    			var tween = agent.DOShakePosition(duration.value, strength.value, vibrato.value, randomness.value, fadeout.value);
    			tween.SetDelay(delay.value);
    			tween.SetEase(easeType);
    			id = System.Guid.NewGuid().ToString();
    			tween.SetId(id);
    
    			if (!waitActionFinish) EndAction();
    
    		}	
    
    		protected override void OnUpdate() {
    			if (elapsedTime >= duration.value + delay.value){
    				EndAction();
    			}
    		}
    
    		protected override void OnStop(){
    			if (waitActionFinish){
    				DG.Tweening.DOTween.Kill(id);
    			}
    		}
    
    	}
    }
    #12421

    Gavalakis
    Keymaster

    Hey,
    Great! Thanks for sharing those 🙂
    I am glad you like NodeCanvas!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.