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.


Messages - Red

Pages: 1 2 [3] 4 5 ... 38
31
Forum Suggestions / Idea for sub-forum: Scripting help.
« on: March 23, 2015, 08:57:35 AM »
Kinda curious if this might be a worthwhile idea.

A sub-forum here on the site for discussion on making custom actions? So, if I wanted to find some assistance making a custom action there'd be a spot I can go to rather than the playmaker help section which seems more like a how-to for the system itself.

Having a section where someone can post for help making scripts isolated from the main section might be something that could help keep the boards a little cleaner maybe.

32
PlayMaker Help / Re: How do I get a component from within a PM script?
« on: March 22, 2015, 02:51:21 PM »
Checked (after a coffee-break) a couple other actions to see how they did their thing... I think I cracked this one... So, have at it. (I have to still finish this up by polishing it up but I tested it and this does work now.

Code: [Select]
using UnityEngine;
using System.Collections;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Character)]
[Tooltip("Simple movement of a character while constrained within a user-defined area.")]
public class ClampedMovement : FsmStateAction
{
private Rigidbody rb;
public enum AxisPlane
{
XZ,
XY,
YZ
}

[RequiredField]
[CheckForComponent(typeof(Rigidbody))]

[Tooltip("The GameObject to move.")]
public FsmOwnerDefault gameObject;

[RequiredField]
[Tooltip("The movement vector.")]
public FsmVector3 moveVector;

[RequiredField]
[Tooltip("The world plane that the 2d input is mapped onto.")]
public AxisPlane mappedToPlane;

[Tooltip("Lateral clamp minimum value.")]
public FsmFloat horizontalMin;

[Tooltip("Lateral clamp maximum value.")]
public FsmFloat horizontalMax;

[Tooltip("Vertical clamp minimum value.")]
public FsmFloat verticalMin;

[Tooltip("Vertical clamp maximum value.")]
public FsmFloat verticalMax;

public override void Reset()
{
gameObject = null;
moveVector = null;
mappedToPlane = AxisPlane.XZ;
horizontalMax = 0.0f;
horizontalMin = 0.0f;
verticalMax = 0.0f;
verticalMin = 0.0f;
}

public override void OnFixedUpdate()
{
DoSetVelocity();
}

void DoSetVelocity()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
rb = go.GetComponent<Rigidbody>();
rb.velocity = moveVector.Value;

switch (mappedToPlane)
{
case AxisPlane.XZ:
go.transform.position = new Vector3 (Mathf.Clamp(go.transform.position.x, horizontalMin.Value, horizontalMax.Value), go.transform.position.y, Mathf.Clamp(go.transform.position.z, verticalMin.Value, verticalMax.Value));
break;

case AxisPlane.XY:
go.transform.position = new Vector3 (Mathf.Clamp(go.transform.position.x, horizontalMin.Value, horizontalMax.Value), Mathf.Clamp(go.transform.position.y, verticalMin.Value, verticalMax.Value), go.transform.position.z);
break;

case AxisPlane.YZ:
go.transform.position = new Vector3 (go.transform.position.y, Mathf.Clamp(go.transform.position.y, horizontalMin.Value, horizontalMax.Value), Mathf.Clamp(go.transform.position.z, verticalMin.Value, verticalMax.Value));
break;
}

}
}
}

I Think I'm going to have to keep in mind this kinda stuff though (and I have no idea if this is the most elegant way of doing it since this is my first time working with custom actions and also seriously working with C# as is.) But for the most part this is a start and possibly a final action.

I know I'll likely have to add in some redundancy and error-checking since I suspect if the values for the borders of the clamping are not filled in it'll cause errors... But at least it's a start.

33
PlayMaker Help / How do I get a component from within a PM script?
« on: March 22, 2015, 01:40:18 PM »
Here's the code that I'm stumped on... I'm trying to use this to apply velocity to the object this is on (while keeping it clamped within a certain zone that the user defines.)

Code: [Select]
using UnityEngine;
using System.Collections;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Character)]
[Tooltip("Simple movement of a character while constrained within a user-defined area.")]
public class ClampedMovement : FsmStateAction
{
public Rigidbody rb;
public enum AxisPlane
{
XZ,
XY,
YZ
}

[RequiredField]
[CheckForComponent(typeof(Rigidbody))]

[Tooltip("The GameObject to move.")]
public FsmOwnerDefault gameObject;

[RequiredField]
[Tooltip("The movement vector.")]
public FsmVector3 moveVector;

[RequiredField]
[Tooltip("The world plane that the 2d input is mapped onto.")]
public AxisPlane mappedToPlane;

[Tooltip("Lateral clamp minimum value.")]
public FsmFloat horizontalMin;

[Tooltip("Lateral clamp maximum value.")]
public FsmFloat horizontalMax;

[Tooltip("Vertical clamp minimum value.")]
public FsmFloat verticalMin;

[Tooltip("Vertical clamp maximum value.")]
public FsmFloat verticalMax;

public override void Reset()
{
gameObject = null;
moveVector = null;
mappedToPlane = AxisPlane.XZ;
horizontalMax = 0.0f;
horizontalMin = 0.0f;
verticalMax = 0.0f;
verticalMin = 0.0f;
}

public override void OnEnter()
{
rb = GetComponent<Rigidbody>(); // <-- Here is where the error is showing up in the console.
}

public override void OnFixedUpdate()
{
DoSetVelocity();
}

void DoSetVelocity()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);

rb.velocity = moveVector.Value;

switch (mappedToPlane)
{
case AxisPlane.XZ:
go.transform.position = new Vector3 (Mathf.Clamp(go.transform.position.x, horizontalMin.Value, horizontalMax.Value), go.transform.position.y, Mathf.Clamp(go.transform.position.z, verticalMin.Value, verticalMax.Value));
break;

case AxisPlane.XY:
go.transform.position = new Vector3 (Mathf.Clamp(go.transform.position.x, horizontalMin.Value, horizontalMax.Value), Mathf.Clamp(go.transform.position.y, verticalMin.Value, verticalMax.Value), go.transform.position.z);
break;

case AxisPlane.YZ:
go.transform.position = new Vector3 (go.transform.position.y, Mathf.Clamp(go.transform.position.y, horizontalMin.Value, horizontalMax.Value), Mathf.Clamp(go.transform.position.z, verticalMin.Value, verticalMax.Value));
break;
}

}
}
}

I know that offering a raw code dump like this might be a little intimidating but I think I've got the clamping mechanics down as that's not reporting any errors... I haven't been able to test it with a preview though since I'm coming up against an error at line 57.

What I'm hoping to do is just applying the velocity (I don't know if I have to add in a world-vs-self space thingamabob but for now I'm only working with it raw as is to see how it goes.)

I'm a bit stumped here. Anyone want to show me what I've got wrong? Is this some layer that I need to dig into since this is a PM action?

(edit: Wasn't sure if this would be more appropriate for Character or Physics in the category... That's a minor thing though.)

34
I'm finally getting off my @$$ and seeing about trying my hand at making a custom action. Mainly because it clicked, if I can put together a complex FSM then I DO have the head for programming in a sense... It's just a matter of knowing how to translate that from the FSM to a code-based approach (and to be fair I do have a decent amount of skill with MaxScript from my training and freelancing as a rigger and it's most definitely a programming language on it's own.)

So here's what I'm wondering. I'm trying to make a system that has movement for the player but clamps it within an area.

What I'm wondering is (and I suspect I'm overcomplicating it a bit) is this... Can I create a drop-down that auto-populates variables the user can input similar to the "Int Switch" action but instead of a number of int variables in that one it's a "Floats/Rect/Vector2" kinda deal?

So, say you choose the "Floats" in the drop-down... It then populates four float values you can input. In the case of the "Rect" it lets you pop in a rect variable and in the case of the Vector2 variable, it lets you do two vector2 vars (one for the minimum and one for the maximum.)

I know this might be biting off a lot more than I can chew since I'm not that skilled with C# but I think having those options would make it easy for someone to choose what they prefer if this is an action that is to be shared... All else failing that, I can work on the four floats thing but I would like to add in that extra functionality if at all possible (without making my computer catch fire, that is.)

Any actions you can suggest I look at (either stock or in the EcoSystem) to gauge what this is like or is this something that something unheard of so far?

35
PlayMaker Help / Constraining/Clamping/Restricting player movement.
« on: March 21, 2015, 01:13:14 PM »
Hello again... I'm trying to figure out an elegant system to see about limiting the player object's movement for a shmup that limits the player from moving outside of the boundaries of the screen.

I've got the data to feed it (where the boundaries of the screen are relative to the player's location in the scene) but I'm coming up against a wall on how to do this as elegantly as possible (without layering on too many FSMs on top of it.)

I'd like to avoid using rigid bodies if at all possible (box colliders at the borders of the screen that are set to prevent the player from moving outside of it.)

Anyone ever crack this one?

36
PlayMaker Help / Re: 3rd Person shooter bullet direction help needed
« on: December 05, 2014, 12:40:49 PM »
I just opened it up recently... Err, not sure what you're trying to accomplish.

Could you repackage it with greyboxes and maybe give a bit more explanation? What I've got doesn't really make much sense since I'm missing a lot of context.

37
PlayMaker Help / Re: Moving platforms help requested.
« on: December 03, 2014, 01:46:02 PM »
And it looks like I may have solved it.

Here's the layout. Expanded actions are the relevant actions.

38
PlayMaker Help / Re: Creating a in-game level editor.
« on: December 03, 2014, 01:21:43 PM »
Though I'm not all that up-to-speed on using it, I have heard murmurings that XML would be a good thing to consider for what you're looking at.

Have you checked into XMLMaker? From what I can gather XML is basically a markup language where you make your own "markup" tags so if you're going with a grid layout system you might benefit from looking into that.

That said, don't ask how to use it of me since I'm still green on XML. :P

39
PlayMaker Help / Re: Moving platforms help requested.
« on: December 03, 2014, 01:17:12 PM »
Okay, so I discovered that adding a rigidbody to the platform won't kill the systems... AS long as I make it kinematic.

So, the "when standing still on the platform" is solved simply by taking the velocity and feeding that directly into the "Set velocity" action in the "idle/standing" action set.

Still trying to figure out the "when moving" bit... Since the actions I have are "every frame" kinds, the first attempt at taking the velocity of the player and platform and adding it every frame gave terrible results (basically, it had me zooming all over the place.)

40
PlayMaker Help / Re: 3rd Person shooter bullet direction help needed
« on: December 02, 2014, 04:37:55 PM »
Downloading (from the PM link) now.

I'll give it a look-see to see what's going on here.

41
PlayMaker Help / Re: 3rd Person shooter bullet direction help needed
« on: December 01, 2014, 10:58:36 AM »
Couple things.

Using the raycast to detect the angle with which to fire the bullet isn't the best since raycasts afaik need to know what angle to fire off at in the first place. So, you already have either a position or an angle already.

If you have that and the reticle is smack-dab in the center of the screen, it's likely that a raycast direction of Y+ local should do it.

As for adding force... Well, that's where "Add force" will be what you'd want. For that you might want to consult the unity docs to see what kind of force you will need (I suspect "impulse" will be the one but ref the manual 1st just in case.)

http://docs.unity3d.com/Manual/PhysicsSection.html

You could I guess also have a "Set velocity" action do it too... But other than that I'm not 100% sure what would work best for your particular situation.

42
PlayMaker Help / Re: Moving platforms help requested.
« on: November 30, 2014, 03:12:11 PM »
So, I've been mulling it over and I think I might have an idea how to adapt the video technique to this one.

Thing is, I need to figure out a way to get the distance that the platform has traveled per-frame (I'm using iTween right now but if that's not advisable I can find a different method but I suspect that may not be required.)

One thing I could do is an "every frame" deal where the platform takes it's current position, compares to the position it was at in the previous frame and does the maths (I'm not the best at it but I believe subtracting the previous from the current would be the most ideal to get the "how far has this traveled.")

Thing is... If I do this in the actual FSM that handles the movement I get it managed cleanly in terms of performance... But that'd then likely turn that set of states into a bit of a nightmare (And I'd have to repeat it for each state such as when traveling right or left.) But if I handle it in a separate FSM such as the platform itself then there's the issue of lag if the functioning of transferring that data (the "Distance travelled" bit) between FSMs might make it lag.

As you can tell, I'm obsessed with performance... But to me a good side-scroller has to have very, VERY tight controls and clean response time... Call me old-fashioned but the oldies-but-goodies such as SMB and MegaMan are my inspiration here.

43
PlayMaker Help / Moving platforms help requested.
« on: November 30, 2014, 02:19:55 PM »
Like the title...

What I need to figure out is how I can get the player to move while they're on a moving platform and move with that platform... It's a standard game mechanic but I'm having a hard time adapting the video tutorial (which deals in code) to PlayMaker.

Here's the video I'm referencing. In code it seems relatively simple... But I'm having a difficult time wrapping my head around how I'm going to get this working using PlayMaker.


Attached is the way I've got it set up for now... The first shot shows the three actions that give me the custom gravity.

I've also got the "set velocity" being what drives the movement... I know it's a little odd but it's the cleanest way I could figure out how to do this since I was getting some really odd results with the "translate" and the character controller would throw some even odder results... So, I am somewhat limited in how I can approach this.

If you want to see other bits of this, feel free to ask and I'll do what I can.

As for how I have tried to address this... Well, I tried the suggestion in another thread to change up the parenting to make it a child of the platform while it's on there but that didn't give me nice results for what I wanted (when I tested I noticed a slight jumpiness as the parenting did it's thing.)

What I have to work with:
-I have a system that detects what it's standing on and determines what it is (if it's a moving platform or not) this uses raycasts. This system is also important to detect when it's grounded or not (since I had to scrap the use of the character controller component, I had to cobble together my own "is grounded" checking system... That is the same system that the "am I on a moving platform?" test uses so I'd rather not have to re-roll that element.

Any ideas? The biggest hurdle I've been trying to figure out is how do I calculate the movement of the platform itself to feed into the "movement = movement + platform movement distance" thing (as outlined in the video.)

I know this is long. Thank you for reading this far.

edit: Yes, this is for an asset store package but also for a game I want to make... That's kinda how I do that part of my side-job... Making games and also selling the bits and pieces for a little extra scratch. If the idea of helping with something I plan to monetize is troubling to you then I completely understand.

44
Action Requests / Re: Is there an action to continually update a trigger?
« on: September 26, 2014, 12:20:39 PM »
Actually, what I'm looking for is an action that isn't going to require me to exit a particular state... Unless you're suggesting I use it only as a way to stash the actual collider it's interacting with instead of just making it not use the event dropdown and only use it to store the collider.

I'll give that a shot to see if I can work that in. Thank you.

45
General Discussion / Re: Purchasing in bulk... For "gifts."
« on: September 15, 2014, 01:33:01 PM »
Cool... So, when I am in a position to do so I then contact you directly? Are you okay with me waiting for when it's on sale? Not going to lie, it's a big-ticket item when it isn't and I do have a budget to keep in mind. ;)

Pages: 1 2 [3] 4 5 ... 38