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 - Red

Pages: [1] 2 3 ... 10
1
So, here's the deal... I'm trying to take on this next side-quest of learning how to control the particles in the shuriken particle system a little more "hands-on" ish...

I've been looking at the scripting reference on Unity's manual site and it seems that some of these functions work with arrays.

Now, don't get me wrong, I like ArrayMaker... But what I'm looking to understand is can I do arrays if all the work that's being done with the arrays are internal to the action? Essentially, I wouldn't (at this point) need to pass array data from one action to another, I'd just want to work on it all in the action script. (This is for now... If it comes to a point where I'd need to pass that data from one action to another I suspect I'd have to find a way to interface with ArrayMaker.)

So, the example I'm testing this on (to stretch my proverbial "legs" as it were) is to simply grab a particle from a system and set it's position manually. The first step that seems to be it would be using the "getParticles" functionality which returns an array. From there it'd just be a "set this particle's position to [x,y,z]"

I think that'd be a decent test to see what sort of headspace I'd need for this... But is this something you could see some potential issues eventually cropping up with regards to the array that the "getParticles" will return?

2
So I needed to use this action but wanted to add in the option of inverting the Y axis...

Here's what I got... Note, I'm not sure if where I placed the changes would be the best or most appropriate... If you can think of a better way to do this that would be cleaner or more efficient, please let me know.

This is the only change to this action's code...

Variable/Field declaration
Code: [Select]
[Tooltip("Invert Y axis")]
public FsmBool invertY;

Added/changed code in the function.
Code: [Select]
float GetYRotation()
{

if (invertY.Value == true)
{
rotationY -= Input.GetAxis("Mouse Y") * sensitivityY.Value;
rotationY = ClampAngle(rotationY, minimumY, maximumY);
}
if (invertY.Value == false)
{
rotationY += Input.GetAxis("Mouse Y") * sensitivityY.Value;
rotationY = ClampAngle(rotationY, minimumY, maximumY);
}
return rotationY;
}

Other than that, the action is identical to the one that comes stock. (I'm unsure what the notes about rigidbodies are about... Maybe as I improve at coding in C# I'll understand it but I'm not 100% certain about it...)

(I tried initially to use a switch/case system but that didn't produce results... So I used the If statement. Not sure if that's the best or most ideal way of doing it... But it is what it is at this point for now.)

3
Something's going bonkers... Not sure how to bring this up... But it's with a custom action I've made.

It's the "Random Switch" one... And when I try to select it in the action browser the action browser tab seems to crash (it results in the picture attached.)

Tried it with another custom action I've made, no bugs (I've tried it with the "encode bit flag" and it's partner "decode" action)

FWIW here's the code for the action as it is... I'm trying to reference this to see about updating the encode/decode bitflag actions so that it's not showing "element 0" for each... It's just a cosmetic adjustment but I felt I should reference this since I somehow managed to get the right labelling.)

Code: [Select]
// PlayMaker is (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.
//
// This action was created in 2015 by Wesley M. Brown of BadSeedGames for use with the PlayMaker system.

//NOTE: This is beta at this point. It may benefit from additional adjustment or tweaking depending on if this action evolves.

using System.Collections.Generic;
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.StateMachine)]
[Tooltip("Randomly calls an event to transition to another state.")]
public class RandomSwitch : FsmStateAction
{
[Tooltip("Declare how many events to choose from.")]
[CompoundArray("Event Switches", "Weight", "Send Event")]
[HasFloatSlider(1, 10)]
public FsmFloat[] weights;
public FsmEvent[] sendEvent;

public override void Reset()
{
sendEvent = new FsmEvent[1];
}

public override void OnEnter()
{
DoRandomEvent();
Finish();
}

void DoRandomEvent()
{
if (sendEvent.Length == 0) return; //If there are no events listed, end this system.

int randomIndex = ActionHelpers.GetRandomWeightedIndex(weights); //Gets a random value with weighted influence.

if (randomIndex != -1)
{
Fsm.Event(sendEvent[randomIndex]); //Fires off the event at the appropriate index that's chosen.
}
return; //Returns to the OnEnter function in case none of the events are determined to have been fired.
}
}
}

No idea what's going on here... I'll continue poking and prodding to see if I can isolate if there's something that's going odd or wrong in another of the custom scripts I've made... But for what this is as things are now this is an issue I've been facing and if you can see what's causing it I'd be very grateful to know what that is so I can fix it (and avoid making that mistake going forward.)

Cheers!

EDIT: I've tested it by removing all my custom scripts from the project... So, that eliminates them... What's left in the project are only the project files, a test level and the ecosystem... I'll test by removing the ecosystem next to see if that's causing it... But I suspect that's not it and it's the action itself that's causing this bug.

EDIT again: Yeah, removing the ecosystem didn't remove this bug... So, I know that's safe (sorry if that sounded like I was doubting but it's part of the troubleshooting process to hopefully isolate what's causing this... And since I'm a coding nooblet this is something I'm not sure of at this point.)

4
Playmaker Help / [Scripting] Creating a raw "Pic-code" image manually
« on: June 26, 2015, 09:42:16 AM »
Okay, this is gonna be a thing that is part "pie-in-the-sky" idea but also something I think if it CAN work might help with data transfer between devices.

The concept is a little complicated and I'm not sure how tall of an order it is but bear with me because I've been bouncing this idea off people that have far more knowledge in coding than I do and all of them agree that something like this is (mostly) possible.

What I'd like to do, however, is do this in PlayMaker... Because, well, why not? Of course the techniques could easily be applied to non PlayMaker applications but I want to stick with PlayMaker first.

PREAMBLE/THEORY:
Since an image file that has four channels (R, G, B and A) that can suggest, via a similar mathematical conversion process for bin, dec, hex, etc it can mean that each pixel has a potential maximum value of 256^4 (So, 4,294,967,296 as a total maximum value that each pixel can represent.) What sort of data can be stored depends on how it's encoded but for this I'm thinking of taking a bit-flag integer value (also because I've got actions that worked with them so this is somewhat familiar territory for me.) Now, for this I'm only going to work with a small file as the end result. (maybe encoding four bit-flag integer values... One for each pixel and resulting in a 2x2px file) so, theoretically, I'll only need a 2x2px max image for this prototype system... I've made a PNG file (png 24 in Gimp) and the end resulting file size is 115 bytes... So, Four bit-flags. Since I am limited to a maximum value of the max an int value can store (yes, a long value holds more but I'm not that confident at being able to handle it quite yet) But for a 31 boolean encoded bit-flag, the max value would be 2,147,483,647 which will fit into one pixel.

So, 31*4 boolean values condensed into a 115 byte file that can be transferred... (for a prototype system... The bit-flags are more intended as proof of concept.)

WHAT:
Data encoding via encrypting it into an image. (Lossless is needed so maybe a BMP or PNG would work as long as it's not losing any information from compression... Still unsure what would be best but I'm going to stick with PNG for now since it's a somewhat universal image format.)

HOW:
This is where I'm at a loss... I've googled how to do creation of image files by referencing stack overflow and it seems I can do that in C#... Whether I can do this in PlayMaker is another issue (and I'm not even sure it can be done in Unity at all but at least it's something I think could be worth trying.)

PROCESS:
Create the code to encode and build the image... then create the code to read and decode the image. Once that's done, do tests to ensure that the data IS being transferred accurately.

Second step would be to try maybe encoding an XML file in some manner... Maybe using the ASCII tables to assign each character a value and then do a raw read/encode/transfer/decode process...

CONCLUSION:
Yes, this is a ballsy idea and a little bit insane... But I think it might be fun to work on it (And this is intended to be an open-source idea... Because I like the idea of keeping it open and free.)

So... Anyone have any tips, advice, suggestions?

And yeah, the working name would be "Pic-code." IT doesn't need one but if it's a viable idea why the hell not give it an easier to remember name than "picture encoding of data for easy transfer" or whatever.

5
Share New Actions / Random Switch
« on: June 04, 2015, 11:19:02 AM »
This action is a simple random switch/event firing off system. I know that you can create this with the "random int" and the "int switch" functions together but that may not take into account weighting a particlar event to give it priority to fire off...  (I'm sure there's likely a way to do a weighted random function but that might be a bit out of my league at this time.)

How to use:

  • Declare the number of switches needed.
  • Slot each event appropriately.
  • Set the weighting to what event(s) you want to take priority and what event(s) you want to be at a default value.

NOTE: If you populate events in here, you'll have to set the weight values for each action at this time. The slider has a minimum value of "1" so if you simply slide it back to it's smallest value that should update from the default "0" to "1." Not sure how to work around that at this time per-se... So, just keep that in mind if you choose to use this.

And as usual, if you see any areas that can be improved upon, feel free to say something about it. Any opportunities to learn something new are always welcome.

6
I'm working on a new action that needs a float slider to control the weighting of random selection (similar to the "play random sound" action.)

But I kinda want it to have the default value in each slider that's populated (this is being done with an array/collection similar to "int switch" and "play random sound") to be between 1 and 10. Sure, the user can put in whatever value they want in the number field but I'd like to make the default be 1 where it's automatically populating 0.

Is there something I'm not doing properly?

NOTE: I've got in the reset option to have it reset down to "1" but this occurs when the number of items that it's to test is increased. New values will be a "0". I know this is a bit nit-picky but the goal is to make it start at "1" for each value. If this isn't something that I can address then I can always make the default be between "0" and "1" if need be but it's just a little touch I think would be nice for the user.

7
Share New Actions / Convert Deg to Rad/Convert Rad to Deg.
« on: June 03, 2015, 11:22:38 AM »
Two actions that convert between deg to rad or rad to deg.

I figured out that in some cases such as when inputting an angle value using Set Property into the Shuriken "starting rotation" value, it would consider the angle that's being put in there a radian value (I think it was... In either case, Shuriken was mistaking one for the other.) This was put together to address that. Since I was making one, I thought it would be sensible to make the other as well.

How to use either action.
  • Input the values to convert.
  • Done.

Pretty simple stuff. If there are any issues, bugs, areas of improvement, be sure to let me know.

8
Share New Actions / (Shruriken) Emit Burst
« on: June 03, 2015, 11:12:31 AM »
This is an action that just goes into a shuriken particle system and emits a burst of particles that the user defines. It's very simple (and adapted from both the Unity manual and referencing the other Shuriken actions that are in existence.)

How to use this action.

  • Input the gameObject that has the particle system on it.
  • Tell it how many particles to emit.

That's it.

When using this, I've used it for a bullet trail and muzzle-flash system... On those, in order to ensure that the particle system is cleanly used, I set the emitter in the Particle window/tab to "none" (this doesn't seem to negatively affect the performance of this action) It doesn't seem to mind if the particle system is looping or not either. So, it's here if you needed something like this.

If you think there could be more shuriken actions made, I can see what I can do about that. I only put this one together because I was getting a little tired of the "Set Property" action having to reset the particle timer, turning it on/off, etc. in order to get a particle to be released (as is the case with the bullet trails.)

If you have any suggestions, critiques, advise, by all means let me know. Anything I can do to help improve my coding knowledge is more than welcome.

9
Share New Actions / Perlin Noise Float
« on: June 03, 2015, 11:03:06 AM »
An action I whipped up the other day for use in a camera shake algorithm... I needed a random value to animate with and I found the perlin noise function.

*NOTE* At this time, the non-declared axis is a randomly chosen value. If the general consensus is that this should be given the option (such as a "use random" bool and a "choose value" float input) to choose where on the other axis this scans across, I can add that in (I think.)

How to use this action:
  • Choose which axis to scan across. This works in either the X or Y. This option is only in there so as to allow some additional variation on the output in case you use multiples of this action.
  • Set the output variable (Float.) *NOTE: At this time I haven't figured out how to make it only use a variable... If you know, please let me know as well as I think having it open to only producing a value and not depositing it into a variable is pretty counter-productive. If you know the action(s) I should reference, please let me know.*
  • Set the multiplier. This is for if you want to either amplify or diminish the value within the action so you can save yourself having to multiply it manually with another action. Just felt right to add it in.
  • Set the noise speed. This sets how fast the sampling will scan across the chosen axis.
  • Set whether this is every frame or only once. (So, if you wanted a random value only once, you can use this... But realistically, the "random float" is probably better... But hey, it's there in case you wanted to use this either only once or every frame.)

This only produces a positive value and if you leave the multiplier as 1 then it will only produce a value between 0 and 1.

If you have any tips, suggestions or critiques of this, feel free to let me know. Anything I can do to improve this action (and by extension my own knowledge/skills at coding) is more than appreciated.

10
Hey, diving into multiplayer stuff with the Photon PlayMaker stuff... I'm trying to see what the demo scenes do in order to figure them out but the "PlaymakerTestGame.Unity" file (the level that has the scene where you either join or create a room) isn't working with a paused error saying that the client is not on master server or not yet ready to call operations.

The scene is from the one downloaded from the wiki... So, not sure what's going on. I'm very green to networking having barely scrapped together a basic one with the basic unity networking stuff (Why I'm choosing photon is that it is hailed as a simpler implementation for things like managing rooms/game instances for multiplayer purposes.)

... so, help? :)

11
Share New Actions / Constrain to Sphere
« on: April 13, 2015, 04:28:32 PM »
So, here's one that I put together to get a vector3 coordinate constrained within a spherical area... But found out that it has some other uses as well.

This is a beta action so I cannot guarantee it's functionality in every case. Hopefully I will eventually be able to incorporate some error catching and refactoring to make it smoother and easier.

This works by taking a vector point and checking it with two variables... Another vector3 which is the center point of a spherical space and the radius of that sphere. It will then take that vector, get the right location and feed that into another vector.

And a use that I didn't aniticipate... If you've used movement and moved something diagonally, you'll notice that it moves just a hair faster than the strict up/down or left/right movement. I don't fully understand why but I suspect this might be that the vectors are being applied both on the X and Y (or whatever plane you're moving on) fully so there's a bit of over-drive. If you feed that through this action, set the radius to 1 (or whatever you're multiplying in the "Get Axis Vector" action) and the center of the sphere at (0,0,0) you can curb that down so that the horiz and verti are working in tandem.

But here's the action anyway. IF you have any comments, crits, suggestions or corrections, please let me know. I want to be able to up my game in terms of coding but I'm still a nooblet to C#. So, if you see potential problems that could arise, please let me know so I can fix them.

12
Playmaker Help / Get Signed Angle to Target... Isn't getting angle.
« on: April 06, 2015, 01:02:21 PM »
Hey, not sure what's happening here... Whether it's how I have it set up or whether the action itself isn't functioning as expected.

Details: Unity5, Playmaker v1.7.8.3, action from the ecosystem.

Basically, I've tried setting it up on a basic object to only get the rotation. I've even gone into the code to insert some debug.log lines to print out the values it's supposed to work with and no matter what I do, it never gives anything but zeros (either in single floats or vectors.)

I have this on an object... And I want it to get the angle of an object that's a child to this object itself... But no matter what I try it's not doing it.

Further testing to narrow down what's going on... I tried this on another object that rotates all the way around slowly... And the odd thing is, when it's past 90 degrees clockwise and before 180, it produces "180." Not sure what this means but it's an odd result that might be either worth looking at or a red herring.

13
Share New Actions / Encode/Decode bit-flags
« on: April 01, 2015, 04:49:38 PM »
Hey there... Two new actions that might help some of you out there if you're looking for a way to manage large sets of data that are yes/no values (such as key-items in one's inventory or maybe a questing system) into bit-flags.

I didn't know what they were officially called but it's basically taking advantage of the 1/0 binary values (1 being true, 0 being false) and converting that into an integer value (and of course, going the other way.)

Note, this IS a beta action set... So, typical disclaimer applies.

How to use:
Tell it how many booleans you want it to handle, assigning those bools in the action to bools in the FSM and also an integer variable that you want it to either run from or store to. Run it.

NOTE: This is important. Since this is beta it's raw and the most important thing here is that the encode and decode need to use the same number of booleans.

There is room in here for some error-checking and redundancy but that might be a bit over my head at this current time. I'll keep nibbling at this going forward but if you use these as recommended there shouldn't be issues.

I've tested with up to 16 bools but since it's using an int as the final storage value, you can make a lot more. (unless it's changed, I believe the resulting int value's max can be something like 2 billion.)

I made this because I wanted a way of storing in the player prefs a simpler value for what weapons the player has unlocked. I only have six but the FSM for that without these was massive and beastly. This cut that down to a much more manageable and easier to read FSM significantly.

EDIT: Performed a stress test... This can handle up to 31 boolean values stored into an integer variable. If you put it at 32, it's at the upper limit of the int's values (since this is, essentially, a power-of-two thing at it's core considering the int-to-bin conversion and the int's max possible value.)

14
I have been thinking on doing this for a while... Since I learned last night that what I had in mind had an official term and process to do it I though now's as good a time as any since any FSMs that I'd put together to either encode or decode a bit-flag integer from a collection of booleans was massively beastly and a terrible headache to keep track of.

So, what I'm wondering here is... The approach I'm thinking of is to use a similar kind of approach that the "Int/Float Switch" actions do and have the user input how many values the bit-flag will represent and present them with that many boolean values to use. (I understand that it would require precision on their part to know how to set it up so that no values are being lost or the result isn't being truncated.)

But when I try to apply a similar structure in the action, I get error CS1729 saying that I cannot make a system like this that only outputs one variable.

I think I can grok why... I suspect that the method (that's what it's term is, right?) is the incorrect one... So, what sort of actions would you suggest I take a look at to decipher how to make the action populate X number of boolean variable slots dependant on the integer that they say they need (eg: "I need 6 slots... so, put '6' in the field and it'll give me 6 slots to use.")

15
Share New Actions / Clamped lerp follow
« on: March 30, 2015, 03:10:58 PM »
EDIT: April 2, 2015. New updated action.
http://hutonggames.com/playmakerforum/index.php?topic=9986.msg47453#msg47453

Here's an action that will make an object follow another.

The way this works is you set up the object, tell it what object to follow, how fast it should move, what distance the object should be from it's target for it to activate and also a clamping mechanism to limit the area it's allowed to move within.

The values for the area are inputted with float values. These are world-space values at this time.

If the clamping values are set to "none" then it will effectively not be limited by that value. So if you want to have it not move lower than a certain point on the X axis but want it to follow as far on the positive, set the "X Max" value to "none" and the "X Min" value to the certain point. This works in all three axes as it is essentially a vector3 lerping function (but at this time I had to break the three axes up to clamp them. If there's a better way to do this, please let me know.)

Could be a starting point for a basic AI system or a camera controller or something like that. This does not control rotation, however. Just position.

I understand this is a little more specialized as the distance checking could be done external to the action but I kinda added it in for the heck of it. If the consensus is that I should remove it for this then I can easily oblige.

As this is another script that I am learning C# with, if you have any suggestions on how to refine or streamline it to be more elegant I'm more than eager to hear your thoughts.

Pages: [1] 2 3 ... 10