Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started by: artician on June 11, 2011, 12:40:58 AM
-
I am in over my head with the amount of information I've been absorbing lately, to such a point that I only discovered this forum, which I have been wishing for for months, today. Well! Time to share some actions!
Here is an action that exposes all the variables within the CharacterMotor script:
using UnityEngine;
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;
[ActionCategory(ActionCategory.Character)]
[Tooltip("Interface to CharacterMotor component")]
public class CharacterMotorAction : FsmStateAction {
[RequiredField]
[CheckForComponent(typeof(CharacterMotor))]
public FsmOwnerDefault owner;
CharacterMotor motor;
GameObject previousGameObject;
public FsmBool CanControl = true;
public FsmFloat ForwardSpeed = 10f;
public FsmFloat SidewaysSpeed = 10f;
public FsmFloat BackwardsSpeed = 10f;
public FsmFloat MaxGroundAcceleration = 30f;
public FsmFloat MaxAirAcceleration = 20f;
public FsmFloat Gravity = 10f;
public FsmFloat MaxFallSpeed = 20f;
public FsmBool JumpingEnabled = true;
public FsmFloat BaseHeight = 1f;
public FsmFloat ExtraHeight = 4.1f;
public override void Reset()
{
owner = null;
}
public override void OnEnter ()
{
GameObject gameObject = Fsm.GetOwnerDefaultTarget(owner);
if (gameObject == null)
return;
if (gameObject != previousGameObject) {
motor = gameObject.GetComponent<CharacterMotor>();
previousGameObject = gameObject;
}
if (motor == null)
return;
CharacterMotorMovement movement = motor.movement;
CharacterMotorJumping jumping = motor.jumping;
motor.canControl = CanControl.Value;
movement.maxForwardSpeed = ForwardSpeed.Value;
movement.maxSidewaysSpeed = SidewaysSpeed.Value;
movement.maxBackwardsSpeed = BackwardsSpeed.Value;
movement.maxGroundAcceleration = MaxGroundAcceleration.Value;
movement.maxAirAcceleration = MaxAirAcceleration.Value;
movement.gravity = Gravity.Value;
movement.maxFallSpeed = MaxFallSpeed.Value;
jumping.enabled = JumpingEnabled.Value;
jumping.baseHeight = BaseHeight.Value;
jumping.extraHeight = ExtraHeight.Value;
}
}
Just look at it. It's so beautiful.
Here is another action which exposes the variables within the Platform Input Controller:
using UnityEngine;
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;
[ActionCategory(ActionCategory.Character)]
[Tooltip("Interface to PlatformInputController component")]
public class PlatformInputControllerAction : FsmStateAction {
[RequiredField]
[CheckForComponent(typeof(PlatformInputController))]
public FsmOwnerDefault owner;
PlatformInputController controller;
GameObject previousGameObject;
public FsmBool AutoRotate = true;
public FsmFloat MaxRotationSpeed = 360f;
public override void Reset()
{
owner = null;
}
public override void OnEnter ()
{
GameObject gameObject = Fsm.GetOwnerDefaultTarget(owner);
if (gameObject == null)
return;
if (gameObject != previousGameObject) {
controller = gameObject.GetComponent<PlatformInputController>();
previousGameObject = gameObject;
}
if (controller == null)
return;
controller.autoRotate = AutoRotate.Value;
controller.maxRotationSpeed = MaxRotationSpeed.Value;
}
}
They're like a cute couple, aren't they? They go well together, which is why I had my swell friend Martijn Zandvliet write them up for me. (I'm a pathetic scripter, but I blame PlayMaker for it).
I hope these are as useful for you all as they have been for me. Cheers! :)
-
Thanks for sharing!
-
hi , thanks for sharing
however im having problem importing them , see the screen shot .
(http://img837.imageshack.us/img837/3809/errorbq.png)
-
Do you have CharacterMotor and PlatformController installed? They need to be installed before you can use these actions.
-
i have them on my main char
-
@mrbdrm: did you ever solve your problem? I'm afraid I can't offer much help. I can say that the addition of a script or other component in my project has forced me to reimport Playmaker several times in the past, which was the only solution that I could find to similar issues. It doesn't appear that the obstacle you're having a problem with is PlayMaker though. I hope you figured it out!
-
Artician, thank you for sharing. Indeed it's very useful.
-
Thanks for sharing looks very usefull.
I have an error during the import though;
Assets/PlayMaker/Actions/PlatformInputControllerAction.cs(12,9): error CS0246: The type or namespace name `PlatformInputController' could not be found. Are you missing a using directive or an assembly reference?
same with the motor:
Assets/PlayMaker/Actions/CharacterMotorAction.cs(12,9): error CS0246: The type or namespace name `CharacterMotor' could not be found. Are you missing a using directive or an assembly reference?
I have both CharacterMotor.js and PlatformInputController.js in my project. My character has both controller and motor attached.
Any idea what it could be?
-
I found the solution:
CharacterMotor.js and PlatformInputController.js have to be placed in /Standard Assets/ folder of your project
Thanks for the action ^^
regards
-
This is just what I needed. Thank you!
-
Great scripts! Just a heads up for all who are using these scripts. Noticed that when you added these actions to an event, such event never FINISHED. At first I thought they were supposed to mimic an always update event, but later noticed that was not the case. So I took a second peek at the code (you can see it for yourself), the code only runs once, since its in OnEnter function, but it never calls Finish(), so it just hangs there forever and never really does anything else, nor it updates every frame.
Thought you should know, in case anyone wanted to change it. I myself thought PlayMaker was acting funny but it seems it was just an oversight :D
-
Hi, I'm trying to implement these scripts and I've received a series of messages similar to mrbdrm
Assets/PlayMaker/Actions/CharacterMotorAction.cs(50,26): error CS1061: Type `CharacterMotorMovement' does not contain a definition for `maxForwardSpeed' and no extension method `maxForwardSpeed' of type `CharacterMotorMovement' could be found (are you missing a using directive or an assembly reference?)
and it repeats for maxForwardSpeed, maxSidewaysSpeed e.t.c. I even tried bigzer suggestion and still no joy, I would love to get this working as I'm following justifun's example here http://hutonggames.com/playmakerforum/index.php?topic=1171.0
thx
-
Awesome, got it to work this morning. I imported the charactermotor action only without the input..cs and it came in without error. Not sure what it was.
-
tried every single folder,still wont install inside the project,where is the project standard assets folder for mac
-
found it final because it was named character controller i didn't realise it was it,another question what do you use to get the character off the floor to jump,ive seen add force but you need a rigidbody for that.