playMaker

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Andrew.Lukasik

Pages: [1]
1
Share New Actions / Draw Line 1.1 [last update: 18.05.2015]
« on: May 20, 2013, 09:01:05 AM »
DrawLine.cs

 Draws line between two objects or points using LineRenderer.

Quote from: version history
1.01 - released
1.02 - <Align In Space Mode Self> now also works with only one target object at hand.
1.021 - bugfix
1.1 - Proper maintenance update. No features added but expect this action to be more performance friendly and a lot more robust.




Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.

// DrawLine.cs version 1.1
// http://hutonggames.com/playmakerforum/index.php?topic=3943.0
// custom action by andrew r lukasik gmail com

using UnityEngine;

namespace HutongGames.PlayMaker.Actions {
[ActionCategory( ActionCategory.Effects )]
[Tooltip( "Draws line between two objects or points using LineRenderer." )]
public class DrawLine : FsmStateAction {

[Tooltip( "Line start." )]
public FsmGameObject startObject;
[Tooltip( "Line end." )]
public FsmGameObject endObject;
[Tooltip( "Start offset or world position." )]
public FsmVector3 startOffset;
[Tooltip( "End offset or world position." )]
public FsmVector3 endOffset;
[Tooltip( "Space." )]
public Space spaceMode;
[Tooltip( "When Space Mode Self is selected Start Object and End Object will execute LookAt each other to align their Z axes" )]
public FsmBool alignInSpaceModeSelf;

[Tooltip( "Material" )]
public FsmMaterial material;
[Tooltip( "Shadow Casting Mode" )]
public UnityEngine.Rendering.ShadowCastingMode shadowCastingMode;
[Tooltip( "Receive Shadows" )]
public FsmBool receiveShadows;

[Tooltip( "start width" )]
public FsmFloat startWidth;
[Tooltip( "end width" )]
public FsmFloat endWidth;

[Tooltip( "Start Color" )]
public FsmColor startColor;
[Tooltip( "End Color" )]
public FsmColor endColor;

[UIHint( UIHint.Variable )]
[Tooltip( "Store GameObject with LineRenderer." )]
public FsmGameObject storeGameobject;

[Tooltip( "Updates positions every frame" )]
public FsmBool everyFrame;
[Tooltip( "Destroy drawn line on exit" )]
public FsmBool destroyOnExit;

//
private FsmGameObject goLineRenderer;
private LineRenderer _lineRenderer;
private Transform _lineRendererTransform;
//
private FsmGameObject localStart;
private Transform _localStartTransform;
//
private FsmGameObject localEnd;
private Transform _localEndTransform;
//
private FsmGameObject startObjectPosition;
private Transform _startObjectPositionTransform;
//
private FsmGameObject endObjectPosition;
private Transform _endObjectPositionTransform;
//
private Transform _startObjectTransform;
private Transform _endObjectTransform;
//

// RESET //
public override void Reset () {
//
startObject = null;
_startObjectTransform = null;
//
endObject = null;
_endObjectTransform = null;
//
alignInSpaceModeSelf = false;
startOffset = new FsmVector3 { UseVariable = true };
endOffset = new FsmVector3 { UseVariable = true };
spaceMode = Space.World;
material = null;
shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
receiveShadows = false;
startWidth = 1.0F;
endWidth = 1.0F;
startColor = Color.white;
endColor = Color.white;
everyFrame = true;
destroyOnExit = false;
//
goLineRenderer = null;
storeGameobject = null;
_lineRenderer = null;
_lineRendererTransform = null;
//
_localStartTransform = null;
_localEndTransform = null;
_startObjectPositionTransform = null;
_endObjectPositionTransform = null;

}

// ON ENTER //
public override void OnEnter () {
if( goLineRenderer!=null ) {
Object.Destroy( goLineRenderer.Value );
}
//
goLineRenderer = new GameObject( "FSM draw line ("+this.Name+")" );
storeGameobject.Value = goLineRenderer.Value;
_lineRendererTransform = goLineRenderer.Value.transform;
//
_lineRenderer = goLineRenderer.Value.AddComponent<LineRenderer>();
_lineRenderer.material = material.Value;
//
_lineRenderer.shadowCastingMode = shadowCastingMode;
_lineRenderer.receiveShadows = receiveShadows.Value;
_lineRenderer.SetVertexCount( 2 );
_lineRenderer.SetWidth( startWidth.Value , endWidth.Value );
DoUpdatePositions();
if( !everyFrame.Value ) {
Finish();
}
}

// ON UPDATE //
public override void OnUpdate () {
if( everyFrame.Value ) {
DoUpdatePositions();
_lineRenderer.SetWidth( startWidth.Value , endWidth.Value );
_lineRenderer.SetColors( startColor.Value , endColor.Value );
_lineRenderer.shadowCastingMode = shadowCastingMode;
_lineRenderer.receiveShadows = receiveShadows.Value;
_lineRenderer.material = material.Value;
}
}

// ON EXIT //
public override void OnExit () {
if( destroyOnExit.Value && goLineRenderer!=null ) {
Object.Destroy( goLineRenderer.Value );
}
}

// DO UPDATE POSITIONS //
void DoUpdatePositions () {
//
if( spaceMode==Space.Self ) MakeSureSpaceSelfHelpersAreOk();
//calculate Start pos:
if( startObject.Value!=null ) {
_startObjectTransform = startObject.Value.transform;
if( spaceMode==Space.World ) {
_lineRenderer.SetPosition( 0 , (_startObjectTransform.position+startOffset.Value) );
}
else {
if( startObject.Value!=null ) {
_startObjectPositionTransform.position = _startObjectTransform.position;
if( alignInSpaceModeSelf.Value ) {
_startObjectPositionTransform.LookAt( _endObjectPositionTransform );
_localStartTransform.localPosition = startOffset.Value;
}
else {
_startObjectPositionTransform.rotation = _startObjectTransform.rotation;
_localStartTransform.localPosition = startOffset.Value;
}
_lineRenderer.SetPosition( 0 , _localStartTransform.position );
}
else {
_startObjectPositionTransform.position = startOffset.Value;
if( alignInSpaceModeSelf.Value ) {
_startObjectPositionTransform.LookAt( _endObjectPositionTransform );
_localStartTransform.localPosition = startOffset.Value;
}
else {
_localStartTransform.localPosition = startOffset.Value;
}
_lineRenderer.SetPosition( 0 , _localStartTransform.position );
}
}
}
else {
_lineRenderer.SetPosition( 0 , startOffset.Value );
}

//calculate End pos:
if( endObject.Value!=null ) {
_endObjectTransform = endObject.Value.transform;
if( spaceMode==Space.World ) {
_lineRenderer.SetPosition( 1 , (_endObjectTransform.position+endOffset.Value) );
}
else {
if( endObject.Value!=null ) {
_endObjectPositionTransform.position = _endObjectTransform.position;
if( alignInSpaceModeSelf.Value ) {
_endObjectPositionTransform.LookAt( _startObjectPositionTransform );
_localEndTransform.localPosition = endOffset.Value;
}
else {
_endObjectPositionTransform.rotation = _endObjectTransform.rotation;
_localEndTransform.localPosition = endOffset.Value;
}
_lineRenderer.SetPosition( 1 , _localEndTransform.position );
}
else {
_endObjectPositionTransform.position = endOffset.Value;
if( alignInSpaceModeSelf.Value ) {
_endObjectPositionTransform.LookAt( _startObjectPositionTransform );
_localEndTransform.localPosition = endOffset.Value;
}
else {
_localEndTransform.localPosition = endOffset.Value;
}
_lineRenderer.SetPosition( 1 , _localEndTransform.position );
}
}
}
else {
_lineRenderer.SetPosition( 1 , endOffset.Value );
}
}

//
private void MakeSureSpaceSelfHelpersAreOk () {
if( startObjectPosition==null ) {
startObjectPosition = new GameObject( "tracking startObject" );
_startObjectPositionTransform = startObjectPosition.Value.transform;
_startObjectPositionTransform.parent = _lineRendererTransform;
}
else {
_startObjectPositionTransform.parent = _lineRendererTransform;
}
//
if( localStart==null ) {
localStart = new GameObject( "local start" );
_localStartTransform = localStart.Value.transform;
_localStartTransform.parent = _startObjectPositionTransform;
_localStartTransform.localEulerAngles = new Vector3( 0 , 0 , 0 );
}
else {
_localStartTransform.parent = _startObjectPositionTransform;
}
//
if( endObjectPosition==null ) {
endObjectPosition = new GameObject( "tracking endObject" );
_endObjectPositionTransform = endObjectPosition.Value.transform;
_endObjectPositionTransform.parent = _lineRendererTransform;
}
else {
_endObjectPositionTransform.parent = _lineRendererTransform;
}
//
if( localEnd==null ) {
localEnd = new GameObject( "local end" );
_localEndTransform = localEnd.Value.transform;
_localEndTransform.parent = _endObjectPositionTransform;
_localEndTransform.localEulerAngles = new Vector3( 0 , 0 , 0 );
}
else {
_localEndTransform.parent = _endObjectPositionTransform;
}
//
}

}
}

2
Set Property action can't reach Line Renderer's specific parameters. Is it a bug or am I missing something?

3
User Showcase / [source files] 2.5D Platformer, Animated Character Example
« on: February 04, 2013, 09:35:41 AM »
CONTENT: animated player-controlled character for 2.5D platform game (v01). Useful for rapid prototyping, testing ideas.

Quote
animations supported:
idle, running, jumping, falling, shoot/attack, hanging from ledge

CLICK TO PLAY(controls: wsad, space and LMB)

Quote
How to install:
1. Download Project files
2. Open project with Unity3D 4
3. Import Playmaker from Asset Store
   (created with v1.4.5)
4. Open scene "level" and hit >

Hi,
 I made this project as a part of last GGJam session so I decided to share it here for anyone interested in learning Playmaker. Keep in mind that I'm still figuring out what is the best FSM architecture for supporting character animation (not using Mecanin but Legacy system yet) for such projects so I'm quite aware that it's far from nicely done ones yet. But still - could be useful as prototype or material for dissection.
Feel invited to comment, suggest ideas or even share your own examples <3!

download project

4
User Showcase / [source files] ChocolateBoy
« on: September 24, 2012, 03:52:38 PM »
Hi there,
 Following @Damian question I just wanted to share here project files for interested newcomers to examine. I tried to make FSM's as simple as possible ("less is more" in PM).



CLICK TO PLAY (controls: arrows and space)


Quote
//subject: simple AI FSM behaviour example for 2D platform game

How to install:

1. Open "project ChocolateBoy" with Unity3D
   (this is only because custom Layer Collision Matrix (Edit>Project Settings>Physics))

2. Extract "ChocolateBoy package.unitypackage"

4. Import Playmaker from Asset Store
   (created with Pm v1.4.3)

5. Run "!delicious.scene"


///////version history/////////
24.09.2012 - first version
25.09.2012 - added functionality to randomly spawn collectible objects and fixed few things


PS: I invite you to share your simple projects' sources too! :)

5
Feature Requests / its time for: Global FSMs
« on: September 18, 2012, 12:32:23 PM »
Hi guys,
I want to propose this surely not new idea of Global / shared FSM's. Meaning:



Problem it's solving:
I have 20 characters and updating their numerous identical FSM's after any minor change is quite unnecessary necessity.


What do you think?

6
Share New Actions / Get Mouse XY[SOLVED]
« on: July 26, 2012, 01:19:17 AM »
GetMouseXY.cs

Description: It combines "GetMouseX.cs" and "GetMouseY.cs" into one action, and adds useful "everyFrame" flag.





Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Input)]
[Tooltip("Gets the XY Positions of the mouse and stores it in a Float Variables.")]
public class GetMouseXY : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmFloat storeResultX;
[UIHint(UIHint.Variable)]
public FsmFloat storeResultY;
public bool normalize;
public bool everyFrame;

public override void Reset()
{
storeResultX = null;
storeResultY = null;
normalize = true;
everyFrame = false;
}


public override void OnEnter()
{
DoGetMouseXY();

if (!everyFrame)
{
Finish();
}
}


public override void OnUpdate()
{
DoGetMouseXY();
}


void DoGetMouseXY()
{
if (storeResultX != null)
{
float xpos = Input.mousePosition.x;
if (normalize)
xpos /= Screen.width;
storeResultX.Value = xpos;
}

if (storeResultY != null)
{
float ypos = Input.mousePosition.y;
if (normalize)
ypos /= Screen.height;
storeResultY.Value = ypos;
}

}
}
}

7
Action Requests / Line Renderer support
« on: March 27, 2012, 09:48:30 AM »
Is it possible to support Line Renderer with PM?

It would add very needful and inspiring new feature to work with!

8
I'm asking this, because when I click play > and after that any action changes value of any Global Variable, then this new value is there even after [] stopping the game.

So my question is - bug or a feature? :)
And maybe what are yours best practices to deal with it

[PM 1.3.2, Unity 3.5.0f5]

9
Action Requests / GameObject to Object
« on: December 04, 2011, 06:19:28 PM »
Ability to convert GameObject to Object (or simply set Object not only via drag&drop) is missing and still very important.

10
Feature Requests / Frequency monitor for loops? (CPU optimization tool)
« on: October 25, 2011, 09:32:00 AM »
I thought about this for a long time - is there any simple way to make PM tell us which loops are making too much CPU delays etc? Is there any simply reachable data here to help us keep performance easier?

Even something like a number visible next to link - telling how many time that link was fired in past X seconds/frames(?) would be very helpful yet

  I write about this because i had a lot of issues with this in the past, and I know that not being conscious about that may be very discouraging as FPS drops rapidly having no idea why (blames goes to PM of course then).
Now I have to allocate some brain resources to virtually monitor that. I know that it wont hurt anybody, BUT - if Playmaker want to be that awesome tool for a designers (not very technical guys) then it could be really wise to address that IMHO

Regards
Andrew

11
Share New Actions / Level Name To String
« on: October 20, 2011, 02:27:42 AM »
LevelNameToString.cs

Description: Returns current level's name as a String


Example: Using it with <Load Level> (from string) - can be very helpful when it comes to working with multiple scenes.
With this action you can store name of a previously played level to go back to it later when needed (sub-locations / interiors etc) or to simply restart scene.


Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.
// micro script by Andrew Raphael Lukasik

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Level)]
[Tooltip("Returns current level's name as a string.")]
public class LevelNameToString : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmString stringVariable;
[RequiredField]
private FsmString stringValue;

public override void Reset()
{
stringVariable = null;
stringValue = null;
}

public override void OnEnter()
{
DoSetStringValue();

Finish();
}


void DoSetStringValue()
{
if (stringVariable == null) return;
stringValue = Application.loadedLevelName;
stringVariable.Value = stringValue.Value;
}

}
}

12
Hi
My performace (in PM editor window) drops down after updating to 1.2.1 very significantly. And I'm not quite sure where to start looking for causes - any ideas?

Occuring:
Only when PM Editor is opened

Possible clues:
-it occurs really often when deleting events (Unity freezes for few seconds)
-it occurs when editing actions, adding/editing states, etc. (effects same as above^)

So far checked:
Real-time error checker switched off - no change



s.o.s.

13
Hi
I have this problem updating my project to Playmaker1.2.1 that action SendEventToFSM is notified as obsolete and in the same time SendEvent (as seen below) has no text-field in "Send Event" space anymore.



^As you can see problem is that target Game Object is virtually unknown before runtime


Anyone know how to fix this? Maybe adding some code to SendEvent.cs?

14
Share New Actions / Restart Level
« on: October 17, 2011, 05:40:26 AM »
RestartLevel.cs

Action to restart current level.

Description: Action restarts current level immediately using one line of code:
Application.LoadLevel(Application.loadedLevelName);

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.
// micro script by Andrew Raphael Lukasik

using UnityEngine;
using System.Collections;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Level)]
[Tooltip("Restarts current level.")]
public class RestartLevel : FsmStateAction
{
public override void Reset(){}
public override void OnEnter() {Application.LoadLevel(Application.loadedLevelName); }
}
}

15
Share New Actions / Round Float Value
« on: September 04, 2011, 04:17:12 PM »
FloatRound.cs

Simple action to round float variables using Mathf.Round

EXAMPLE:
source Float: <23.2463462>
result Float: <23>

Description: Returns f rounded to the nearest integer. If the number ends in .5 so it is halfway between two integers, one of which is even and the other odd, the even number is returned.
(documentation)

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.
// small additional action by Andrew Raphael Łukasik

using UnityEngine;
using System.Collections;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Math)]
[Tooltip("Rounds Float Variable.")]
public class FloatRound : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmFloat floatVariable;
public bool everyFrame;

public override void Reset()
{
floatVariable = null;
everyFrame = false;
}

public override void OnEnter()
{
floatVariable.Value = Mathf.Round(floatVariable.Value);

if (!everyFrame)
Finish();
}

public override void OnUpdate()
{
floatVariable.Value = Mathf.Round(floatVariable.Value);
}
}
}

Pages: [1]