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

Pages: [1] 2 3 ... 8
1
The farthest path you describe is the distance from the NavMeshAgent to its current destination, but that isn't needed in your case.

You should grab the 'Path Finding' package from the Ecosystem if you didn't already, since it contains an exhaustive list of actions that covers pretty much all the basic stuff you can do with Unity's built-in pathfinding system. Everything more complicated should be created by combining these to achieve the desired result.
My own custom actions might also come in handy, namely "Find Closest Agent" and "Nav Mesh Agent Move To", which I've added to the attachments or can be found in the Ecosystem.

In your scenarios, everything that shouldn't be passable needs a "Nav Mesh Obstacle" component (use as many as you need), which represent a box or capsule collider (you can also make the capsule collider act as a sphere by reducing the height) that the NavMeshAgent not only doesn't go through, but also takes into account when generating the path, which means that it will automatically go around the obstacle, if you enable carving on it (this carves the collider size into the underlying NavMesh, making that section impassable by any agent | you can also make the collider bigger than the object itself, which increases the offset to that object when going around it and the collider boundaries of obstacles can even overlap or be nested to combine them).

For your first scenario you don't want your player to move to the goal directly, but rather add subsections where the agent moves to first (in this case add an empty GameObject where the gate is and set this as the target the agent should go to; after that you could warp the agent to the goal with the 'Agent Warp' action | I prefer to use empty GameObjects as placeholders when it comes to animations or subtargets, because you can move them more easily around in the editor than specifying Vector3 positions).
Here you can use the "Nav Mesh Agent Move To" action and because you added an obstacle component to the barriers, your agent will automatically search for the shortest way around them to the gate (of course you always need to bake your NavMesh in the 'Navigation' window when changing anything).

The second scenario is a bit more complex and I'm not quite sure how to achieve this, but still got some ideas:
- if those blocking units are static, by giving each of those a NavMesh Obstacle component and checking if the path is invalid/stale (don't know which one :P)
- by shooting a NavMesh Raycast (they are different from normal Raycasts) to the goal with the action "Agent Ray Cast" and checking if it hit any of the units
- by creating a path and continuously sampling its position ('Agent Sample Path Position'), then using that position with my "Find Closest Agent" action (every blocking unit would then need a NavMeshAgent component) and seeing if the distance is in a certain threshold (if that distance is bigger than your players size it should be able to pass through for example)

In the end you should experiment with the given actions from the Path Finding package or try to alter your approach.

2
@Marc Saubion
I though of that too and had that initially in the additional suggestion list, but the problem with that is, that you have to first set a field to 'None' before creating a new variable, which deletes/resets the value in that field.

3
I just came up with a great idea that would drastically improve managing variables and save quite a lot of time:

Directly setting the variable value when creating a new one in any action


(emphasis on the field between "animDelay" and the "Create Variable" button)

So whenever you want to add a new local or global variable or convert a hard-coded value to one, you can immediately set the value in the same small pop-up that allows you to set the name of the variable (a similar example would be the pop-up when adding an aspect ratio to the game view where you can specify multiple values).

Like that you wouldn't need to switch to the variables tab, search for the variable, select the variable and select the value field of the variable. That's more than 3 clicks and can add up to quite a lot of time when dealing with lots of variables every user would save with that option. And if you want to replace something with an FsmVariable you would also have to copy over that value to the variable-field in the variables tab, which is neither ideal nor any fun.


If you consider implementing this, here are additional suggestions that would make this most useful:
- the value field should match the type of variable to add (should be even enough space for the 3 fields of an FsmVector3 variable and you don't need to add any label next to it anyway)
- the default value for the variable type should be pre-set, so that it's complete optional to set the value directly
- on an object-field it should detect the type of object to be put in, if defined (e.g. Collider, AudioSource, ...);  it should also be possible to drag and drop matching objects into that field

4
Feature Requests / Re: Reset bool option on standard get next actions
« on: April 14, 2018, 02:46:31 PM »
I actually added a reset button to those default "get next" actions a short while ago while working on the DialogManager for my game, without even knowing that there seems to be a demand for that functionality.

As it turns out, there couldn't be anything more trivial: since those actions rely on caching the current index in a private variable which don't get reset when re-entering the action, so you have to do it yourself at the start of OnEnter(), like so:
Code: [Select]
if(reset.Value) nextItemIndex = 0; reset.Value = false;(as you can see I even added that the reset bool automatically gets set back to false after resetting the index, since there's no plausible reason to keep resetting the action, and if there is, one could just keep the bool set to true in the action after that "get next" action).

You can find the two customized actions for 'Array Get Next' and 'Get Next Child' in the attachments and I would also urge HutongGames to add that option to the standard actions, so that no one has to rely on these or their own custom actions just for that function (even though you rarely need it, it's very nice-to-have if one does).

5
Share New Actions / Re: ArrayList Find GameObjects Inside Collider
« on: April 13, 2018, 03:25:30 PM »
Yup, that was a mistake on my part.
In the original actions the GameObjects in the scene got searched by tag with the function "GameObject.FindGameObjectsWithTag()", which requires a tag to be specified and doesn't seem to allow the 'Untagged'-tag.
Since I naively assumed that it would just work to set the 'Untagged'-tag by default and only tested both actions with a specific tag, I didn't think 'Untagged' would cause any trouble.

I fixed this problem, which means you'd need to re-download the actions from the Ecosystem. Sorry for the inconvenience.

I also re-worked both actions to not only allow to filter by 'Untagged'-GameObjects but also made that tag filter completely optional, meaning you now can set the tag to 'None' and it ignores that tag filter, resulting in listing every GameObject regardless of the tag. The layer-filter is unaffected and can be used in conjunction with the tag-layer to narrow down, which GameObjects to capture.
Additionally, I implemented an error check when the collider target wasn't set and that when toggling the tag from 'None' to the tag-list it shows 'Untagged' instead of an empty entry (uses OnGUI so it might not always do that, but that would be just a minor inconvenience if not).


P.S.: If anyone is interested to know how any of these actions work (for clarity or performance reasons), here a short rundown:
- the action searches for each active GameObject in the scene (dudebxl's versions directly by tag, which is slightly more performant but forces you to define a tag, while mine search for any Object of type GameObject; in either case these actions should be repeated/used as scarcely as possible to reduce that overhead of constantly going through all GameObjects in the scene);
- it checks for each found GameObject if it matches the specified tag and layer;
- skips any GameObject that doesn't contain an appropriate collider component;
- gets the bounds of each collider, sees if it intersects the bounds of the user-defined collider and only lists the GameObjects that match all these criteria

6
You might also need to define the object type with the attribute 'ObjectType', like so:
Code: [Select]
[ObjectType(typeof(AudioClip))]
[ArrayEditor(VariableType.Object, elementName: "Clip")]
public FsmArray myArray;

In the list of supported action attributes you can also see that the "fairly new" attribute 'ActionTarget' could be exactly what you're looking for (I haven't seen any use for it yet and never tried it myself, so I don't know for sure).

Sidenote: The Reset() function is only to specify default values for the action variables so that shouldn't be the place to define what type of object an array is supposed to contain.

7
Playmaker Help / Re: ArrayListSort with vector3
« on: April 11, 2018, 12:55:55 PM »
Try
Code: [Select]
pos.Value.z
since your "pos" variable is probably a FsmVector3 and those FsmVariables are wrappers for their original counterparts containing additional extensions and support for their own custom PlayMaker fields.

So on every FsmVariable (like FsmGameObject, FsmString, ...) you access the value of that variable wrapper with .Value, check if it's set to none (in the Action) with .None and so forth.

Once you write pos.Value it behaves like a normal float variable and thus can be modified like one but note that when you want to set/overwrite the value for pos you'd have to also asign the new value to pos.Value.

Example:
Code: [Select]
//store the current value of pos
float tmpPos = pos.Value;
//this won't change the value for pos...
tmpPos += 3f;
//...you also have to overwrite the value of the FsmVector3
pos.Value = tmpPos;
---
//you could also directly set the value without another variable
pos.Value += 3f;

8
Playmaker Help / Re: CustomActionEditor Set FsmVar[] variable Issue
« on: April 04, 2018, 01:32:00 PM »
I replicated your setup because this remote maintenance proves quite difficult :).

It turns out that there is a problem with resizing the FsmVar[] xxxxx by creating a new object ("new FsmVar[fsmvars.Count]") and trying to use it immediately afterwards.

You can test it yourself by throwing a Debug.Log() at the end of BuildFsmVariableList(): whenever you try to do something with xxxxx, wheter updating, setting or getting a value to/from it, it seems to break the function without throwing any error, and anything afterwards won't get executed (as if that action variable gets corrupted or isn't accessible).

When you comment that resizing process out (
Code: [Select]
//action.xxxxx = new FsmVar[fsmvars.Count];), you'll see that it reaches the end of that function.

It might be that something needs to be done to the FsmVar[] after resetting/resizing it, but I think your best bet would be to go for a different collection variable if possible, like FsmArray which natively has a .Resize() function and can also hold any object type.
If you do, you should know that with FsmArrays you need to do the following when resizing/manipulating them (kind-of pseudo-code):
Code: [Select]
FsmArray array;
...
array.SetType.(...);
array.Resize(...);
for(...) {
array.Set(i, ...);
}
array.SaveChanges();


While setting up your scenario I also noticed that you were missing the UnityEditor using directive ( "using UnityEditor;" ), to get things like EditorGUI to work and you'd need to set the types to string before filling it with string values:
Code: [Select]
action.xxxxx[v].Type = VariableType.String;

I guess I can't help you any further than that. Maybe Jean or someone else sees this and might know what is going with FsmVar[]'s in such a scenario, but It could be that using an FsmVar[] is not be the desired approach and the reason that something like FsmArray exists.

9
Playmaker Help / Re: CustomActionEditor Set FsmVar[] variable Issue
« on: April 02, 2018, 12:32:11 PM »
Oh sorry, I thought PlayMakerUtils where a native thing in PlayMaker, but it rather seems to be an extension to it. You can get it from here (click on 'Clone or Download', 'Download ZIP', extract and put it in your "Assets" folder).
In there are also the helper methods "RefreshValueFromFsmVar" and "GetValueFromFsmVar" which might also help you out, but I think I the problem might be with how you set the variable in each single FsmVar:
try
Code: [Select]
action.xxxxx[v].SetValue(fsmArray.Name);or
Code: [Select]
action.xxxxx[v].stringValue = fsmArray.Name;instead of
Code: [Select]
action.xxxxx[v].variableName = fsmArray.Name;because ".variableName" seems to be the name of the FsmVar variable, not the value that you want to set.

Further thoughts:
When you tried the code in OnGUI() did you also return true at the end, so that it updates whenever something changes in that action? You could also try to put the "DrawDefaultInspector();" at the end of OnGUI() before returning true, so that it only draws the fields after you've modified their values.
Also IIRC, PlayMaker already provides a list of all FSMs in the current scene, just like "Fsm" gives you the current fsm as a variable or "Owner" returns the GameObject of the current FSM, but I don't remember how to access that list. Maybe you find something of that sort so that you don't have to search them through the resources.

10
Playmaker Help / Re: Color Picker Confusion
« on: March 29, 2018, 05:42:28 PM »
I think the main problem is that you normalize the mouse position in 'Get Mouse Position', while setting the space in 'Raycast' to be local ("Self"). If you normalize any screen related measurement, you convert it from local space to view port space (wich is the current point on the screen in relation to the corners, a.k.a. bottom left is 0,0 | top left is 1,1 | middle of the screen is 0.5,0.5). So if you untick that, both actions should be in local space.
I've also read on a similar problem, that Unity flips textures on the y axis internally and I doubt that 'Get Pixel Color' has taken that into account, so you might need to invert the "Int_TextureCoord_Y" variable before 'Get Pixel Color' (by using 'Int Operator' and multiplying with -1).
Also you haven't set a GameObject in your 'Raycast' action. I assume you'd need to set the camera that can display the texture in there and make sure that it is in front of the texture, otherwise you'd have to flip the z-direction.

That 'Get Pixel Color' requires int variables is actually correct, because it uses the pixel of the texture to determine the current position, which are expressed in natural numbers.

In general I'd suggest that you enable Debug-mode (at the bottom of the 'State'-tab next to "Hide unused"), then you can see all the runtime values of set variables, which makes it easier to see on which action it starts to give an unexpected result.

I could also imagine that the 'Get Raycast Hit Info Extras' action is either not the right choice for this endeavor or doesn't work correctly.

11
Playmaker Help / Re: Jump problems
« on: March 29, 2018, 05:15:27 PM »
Some thoughts/suggestions:
- you seem to loop this state through the 'Wait' action every 0.15s, which might be the source for your inconsistent results, try having that action disabled
- you use 'Get Button Up' to detect the key press, which means that it only gets fired when you release the key; you might want to try 'Get Button Down' to fire the moment you press down or use 'Get Button' and check the bool that you get from that in 'Bool Test' every frame if you want your character to only go up as long as that key is pressed
- if the problem has something to do with the physics, try playing around with the mass, drag and angular drag values on the RigidBody to see if it behaves in a more desirable way

Alternatively you could also set your 'Add Force' action to not run every frame,  set its force mode to "Force" or "Impulse" and reduce the Y value until it jumps more naturally. Then you only boost it up once when entering this state instead of constantly applying a change in velocity, which resulsts in inaccurate physics behavior anyway.

12
Action Requests / Re: Timed activate game objects
« on: March 29, 2018, 04:56:20 PM »
I extended my "Activate Game Objects"-Action to support a delay between each GameObject and to run it every frame. You can find the extended version in the Ecosystem as "Activate Game Objects Advanced" (Unity 5 and up) or in the attachments.

13
There are actually GitHub repositories that contain all Ecosystem actions divided into different Unity releases (currently U4, U5 and U2017). You would just need to download them as a .zip, extract them to the same folder and under 'Assets\PlayMaker Custom Actions' you would have all actions that are also prevalent in the Ecosystem.
That's still a bit of manual labor, but seems to be more feasible than entering each letter into the Ecosystem and dowloading each action manually.

Even though the packages are also in a separate repository, it should be better/faster to download those from the Ecosystem.

Additionally, any actions that requires another third party asset are in the misc repository, but from there you should be careful to only include those actions of which asset you have in your project, otherwise you'll find yourself with a lot of errors.

It might also be possible to use GitHub yourself and clone those repositories into your project to shorten the process.

14
Playmaker Help / Re: CustomActionEditor Set FsmVar[] variable Issue
« on: March 29, 2018, 01:45:31 PM »
The first thing I noticed (and probably also the main reason for your problem), is that you don't run the main logic in OnGUI(), but in OnEnable().
I've created a template a while ago that demonstrates how to authorize a basic custom inspector, which you can find here.
In there you can also see that OnEnable() is only for resource heavy initialization, since it doesn't update as often as OnGUI().

If that doesn't help, you could try to update the individual FsmVar's with "PlayMakerUtils.ApplyValueToFsmVar()".


P.S.: FsmVar's and FsmArray's behave differently from each other FsmVariable by design: FsmVar's have to be updated before you use them (but you already seem to do that) and with FsmArray's you need to define the variable type before setting/changing variables and in a repeating action it needs to be cleared at the start, but that just as a side-note.

Also remember that any Editor-Script cannot be executed in your build, that's why you have to reference variables from the base script, because Unity only saves the values of those during runtime.

15
Playmaker Help / Re: How to limit the number of objects created
« on: March 29, 2018, 01:03:52 PM »
No, that shouldn't be necessary.

You can use a global variable to store the amount of spawned bullets (in the "Variables"-Tab right-click on the int variabel and move it to the globals, if not already).

Wherever you spawn your bullets, you check beforehand if that global int exceeds the limit with the action 'Int Compare' and only continue if it doesn't.
After you spawn a bullet you increment that global int with 'Int Add' and where your bullets get destroyed you decrement that variable also with 'Int Add' but setting the value in this action to -1.

You might want to reset that global int to 0 when the scene loads, to make sure that this counter starts fresh.
If you spawn and destroy the bullets in the same FSM, you could also use a local int variable.

Pages: [1] 2 3 ... 8