Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: blackant on August 03, 2018, 02:46:49 AM

Title: cinemachine target group
Post by: blackant on August 03, 2018, 02:46:49 AM
Hello,

i'm trying to create an action to set Cinemachine TArget group with dynamic transforms, usefull if your targets are not already instanciated when you start the game.

the thing is i don't know how to achieve this code...

Code: [Select]
using Cinemachine;
using UnityEngine;

namespace HutongGames.PlayMaker.Actions.ecosystem.cinemachine
{

[ActionCategory("Cinemachine")]
[Tooltip("Modify Cinemachine Target Group")]
public class CinemachineTargetGroupEditor : FsmStateAction
{
[RequiredField]
[Tooltip("The Cinemachine virtual Camera")]
[CheckForComponent(typeof(CinemachineTargetGroup))]
        public FsmOwnerDefault gameObject;

[RequiredField]
[UIHint(UIHint.Variable)]
[ObjectType(typeof(Transform))]
public FsmGameObject[] storeObjects;
private FsmObject storeTransform;

[ObjectType(typeof(Transform))]
private FsmObject[] touslestransforms;

public FsmBool everyframe;

public override void Reset()
        {
            gameObject = null;
storeObjects = new FsmGameObject[0];
storeTransform = null;
        }

// Code that runs on entering the state.
public override void OnEnter()
{
SetTargetGroup();
            Finish(); 
}

// Code that runs every frame.
public override void OnUpdate()
{
SetTargetGroup();
}

void SetTargetGroup()
{
if (storeObjects == null ) return;

for (var i = 0; i < storeObjects.Length-1; i++)
{
var go = storeObjects[i].Value;
storeTransform.Value = go.transform;

touslestransforms[i]=storeTransform.Value;
}
}
}

}
Title: Re: cinemachine target group
Post by: jeanfabre on August 20, 2018, 03:07:08 AM
Hi,

 Sorry for the delay in reply, I was on vacation.

 Did you get some progress on this?

 Bye,

 Jean
Title: Re: cinemachine target group
Post by: Padenlee on January 16, 2020, 11:52:09 AM
Bump my dude
Title: Re: cinemachine target group
Post by: jeanfabre on January 17, 2020, 03:18:24 AM
Hi,

 Ok, made that action so that you can set the target groups. Please download from the Ecosystem Browser.

 you can define the weights and radiuses as well, but leave them to none and they will bet set to default.

Let me know how it goes.

 Bye,

 Jean