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

Pages: [1] 2 3 ... 34
1
Share New Actions / Re: A* pathfinding (stable 0v841)
« on: March 02, 2015, 01:35:46 AM »
I don't have access to my desktop right now, I'm sorry for the false hopes, I was sure it'd work for pro as well, but apparently the rvo controller has been replaced. I will have to look into it this evening.  :-\

2
Share New Actions / Re: A* pathfinding (stable 0v841)
« on: March 02, 2015, 12:52:09 AM »
You're using pro?
If so remove the AStarPlaymakerActions/FsmDummy folder. This is the version for free users. As a pro user you don't need the "dummy pro scripts"

3
Share New Actions / Re: A* pathfinding (stable 0v841)
« on: March 01, 2015, 10:10:58 PM »
UpdateGraph and CreatePathTo were missing, quickly wrote them. I ported CreatePathTo to cs and renamed it to capital letters so Playmaker may or may not update your references.
Edit : and they do work in Unity 4.6

4
Share New Actions / Re: A* pathfinding (stable 0v841)
« on: March 01, 2015, 09:40:47 PM »
which graphs are you using?

5
Share New Actions / Re: A* pathfinding (stable 0v841)
« on: March 01, 2015, 03:28:50 PM »
Ok, on second glance, my code seems even worse than I had previously thought. Here's a barebone-version containing a move-to action (which is like half the code of this entire project :D ) which features everything but the auto option which I think stopped working in v0.2 or so anyway :D UpdateGraph, UpdateGraphArea, GetNearestNodeWalkability, IsPathPossible, WillPathBePossible should also work again. The rest is not included for now. I want to focus on each script, comment each section , refactor it for the sake of readability and generally make it faster and better first. Also, I'm only working on v4.6 free for now, pro will come right after, then I'll make it work on v5 which should be released publicly anytime soon.

If you're upgrading your project please make sure to backup. I've made some structural changes so you'll have to remove all FSM actions before loading the new ones into your assetfolder. You will also need to install the newest A* package.
If you have a project and require certain other actions before you can upgrade please post them here and I'll prioritize them.

EDIT : Also, please tell me the graph types you're using. I'm using GridGraphs all the time and especially navmeshgraphs and quadgraphs may cause issues since they now save their nodes in a different format (no more arrays for them)

6
Share New Actions / Re: A* pathfinding (stable 0v841)
« on: January 29, 2015, 11:44:50 AM »
Color me surprised! How did this thread stay alive for so long?! I had disabled all updates on this post when I started studying what I found an incredibly hard uni course (Molecular Biotechnology). Then I realized a year later that I just can't go without programming, so I switched to CS, which means I have quite some spare time on my hand. Without PaulH's PM this would never have come to my attention again.

 I will update this project again to work with Unity 4.6 and 5 as requested. I'll also clean up the code base as it's quite horrendous (this was my first Unity plugin and my first experience with js/c# for that matter). I won't add functionality though, I might even remove WIP parts that don't make much sense on their own.

My last exam for this semester will be mid next month. Afterwards I will tackle this project.
Do answer me one thing though : Why are you guys still interested in this plugin? Doesn't Unity's own pathfinding work just as well in most situations? I have never used it but looks powerful.

7
Share New Actions / Re: A* pathfinding (stable 0v841)
« on: March 06, 2014, 02:50:46 PM »
Thank you Grofit for all your wonderful work!

I'm sorry to keep you guys waiting. I feel bad for it, but I'm still in my exam phase for about a month. I do not know if I can get back to this any sooner. I may be able to go over the more tricky bugs over the next days though. If it's not too much, that is.

Cheers,
Sven

EDIT: (reading backwards here) Yes, there is no pooling integrated. I had problems with memory leaks the last time I tried to integrate it. But that was a long time ago and I'm not sure I did it correctly :D

@ Skibbejak
your errors most likely indicate that you have some scripts twice. Do you perhaps have both the js and cs version installed at the same time?

8
Android Help / Re: Get info from plugin to a global variable
« on: February 24, 2014, 06:49:57 AM »
Hi,
I've been working for zombie_farm already, so I took this small contract and he kindly agreed to my putting the answer on the forums as well. I didn't know how much he knew about programming, so I started pretty much at square one, but I guess it may still be useful for some people :)

So what I'm doing is I start off of the RandomFloat.cs script. I create a new file, name it GetSeekIPosition and paste the entire code from RandomFloat inside. Then I change the name of the class (look for "public class XXX" in the script) from RandomFloat to GetSeekIPosition. Make sure that it is the same as the filename. Now it should look like this :

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

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Math)]
[Tooltip("Sets a Float Variable to a random value between Min/Max.")]
public class GetSeekIPosition : FsmStateAction
{
[RequiredField]
public FsmFloat min;
[RequiredField]
public FsmFloat max;
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmFloat storeResult;

public override void Reset()
{
min = 0f;
max = 1f;
storeResult = null;
}

public override void OnEnter()
{
storeResult.Value = Random.Range(min.Value, max.Value);

Finish();
}
}
}


Ok, so now let's make it do the stuff we want. You said the function in your plugin is defined as
Code: [Select]
public int GetSeeklPosition() // //return milisecondPublic means it can be used from any other script(as opposed to for example private, which means that only the script the function is in can actually use it) , int means it returns an int variable, and the empty brackets mean it does not need any input. What this means, is that we just need one single variable for the output, and that variable has to be an int variable. However, for playmaker to be able to offer the "plug-in-a-variable" feature you're used to, you need to use an FsmInt instead of and int variable.

So now I deleted the unnecessary variables and changed the Type of the storeResult variable from FsmFloat to FsmInt. I also remove the min and max variables from the Reset function.

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

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Math)]
[Tooltip("Sets a Float Variable to a random value between Min/Max.")]
public class GetSeekIPosition : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmInt storeResult;

public override void Reset()
{
storeResult = null;
}

public override void OnEnter()
{
storeResult.Value = Random.Range(min.Value, max.Value);

Finish();
}
}
}

Now, when Playmaker goes through your states it calls the OnEnter function on the first action. Then it waits until that action sends the global event (that is not programming lingo :D ) "Finish". Then and only then it goes to the next action in the state and does the same thing again. So obviously we want our storeResult variable to get filled with a value when the action is called. So what we do is we first get the result of our function, which we do by calling it like this :
Code: [Select]
GetSeeklPosition();and since we want to save the int value this gets us, we say that our variable "storeResult" is equal to the result of the function. This looks like this:
Code: [Select]
storeResult = GetSeekIPosition();
Now, if you remember, the definition of the GetSeekIPosition function was
Code: [Select]
public int GetSeekIPosition();while our storeResult was defined as
Code: [Select]
public FsmInt storeResult;The difference between int and FsmInt is like apples and the apple bowl to Unity. However, our apple bowl has apple inside, which enables us to equal the apples in the bowl to the apples we get. In actual code our FsmInt has an int variable inside. This int variable is called Value. To use it, we can just type
storeResult.Value
And in turn, this allows us to rewrite our previous statement as:
Code: [Select]
storeResult.Value = GetSeekIPosition();
Awesome. We're almost there. But if you were to compile the script right now, there would be one error left. It would, in everyday terms say : "What do you mean by GetSeekIPosition? There is no function like that in your script!". And that is true. So what we need to do, is make Unity understand where the GetSeekIPosition is coming from.

In this case it's a tad tricky, because I don't know whether there's a "global" (called static) class that has a the component we need as a variable.
Let's create a new input variable called "EasyMovieTextureComponent" which is of the type of the class the component is:
Code: [Select]
public EasyMovieTexture EasyMovieTextureComponent;Adding this to the script will allow you to drag and drop your comonent from the Inspector into your playmaker action, provided that it is called EasyMovieTexture (which I doubt, but I couldn't find any documentation online).

This way we can use the same trick we used with the FsmInt to define where the GetSeekIPosition is. So if we type :
Code: [Select]
storeResult.Value = EasyMovieTextureComponent.GetSeekIPosition();Unity should be able to understand it.

Another thing you will often see in actions are null checks. This is a fancy term for checking, whether a variable has a value assigned to it. Imagine you were the UnityEngine, and you were told to use the EasyMovieTextureComponent variable to call GetSeekIPosition. Now, what would you do, if the EasyMovieTextureComponent was empty. How would you call the GetSeekIPosition? Well, you couldn't, you'd have a midlife crysis and throw a tantrum. Unity does exactly that, but it has no way of knowing what to do next and instead of a tantrum, it throws an error. Unless you specifically expect the error, this is fatal and your entire FSM will stop. To avoid this, we have null checks :D In our case, it looks like this :
Code: [Select]
if(EasyMovieTextureComponent == null){
    Finish();
    return;
}
This makes your action stop before it even runs into the fatal error, by detecting that the variable has no value. If it does have one, it will just be skipped.

And this is it really. All you need to do is replace "EasyMovieTexture" with whatever it is the component is really called , and your done. Here's the entire class :

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

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Math)]
[Tooltip("Sets a Float Variable to a random value between Min/Max.")]
public class GetSeekIPosition : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmInt storeResult;

                [RequiredField]
                public EasyMovieTexture EasyMovieTextureComponent;

public override void Reset()
{
storeResult = null;
                        EasyMovieTextureComponent = null;
                }

public override void OnEnter()
{

                                                      if(EasyMovieTextureComponent == null){
                                                            Finish();
                                                            return;
                                                      }

                        storeResult.Value = EasyMovieTextureComponent.GetSeekIPosition();

Finish();
}
}
}

One thing that I just realized is that you probably have to add a so called namespace reference to your script.[EDIT: In this case, you apparently do not need to do this. This is very rare and actually very bad code imo.] In c#, they are nothing more than

Code: [Select]
using XXX;
at the top of your script. You can see that UnityEngine is already implemented that way. Namespaces are kind of like categories you can put your script in. For example, in your script you are defining your namespace as

Code: [Select]
namespace HutongGames.PlayMaker.Actions
{
   ....
}

So if you want to use your class in another script, you would have to add

Code: [Select]
using HutongGames.PlayMaker.Actions;

...to the top of the script so that Unity understands what class you mean.

[This is all you need to do in your case. Just find the right namespace and add a "using RightNamespace;" to the top of the script. The rest of this mail is an explanation and a tad dry I fear :D ]

If you don't put your class into a namespace, then Unity can always find it just by its' name, but most plugins use namespaces because it might just be that you have another plugin that defines a different class with the same name.
Eg. if I create a new Terrain plugin, I'd probably create a Terrain class. But since Unity already has a Terrain class, it would not know whether to use it's own class or my new one if I used it in a script.
If however, I put my Terrain class in a namespace X, I could start my script with "using X " instead of "using UnityEngine", and now Unity would always use the Terrain that is in the namespace X.

However, this depicts a problem, because what if I wanted to use Terrain from the namespace X, but everything else from UnityEngine (it contains all kinds of important stuff). I can't just remove the "using UnityEngine", because then  it would no longer understand where all the classes like "Vector3" etc are. Well, in this case I have two options :

1) I can use a namespace just like any other normal variable. What I mean with this is, if you remember the fruit bowl example, I can get the content of a class like this :
Code: [Select]
FruitBowl.Banana

This is what we used on the FsmInt (FruitBowl) variable to get the int (Banana):

FsmInt.Value


Therefore it is totally acceptable for Unity if you define a variable like this :
Code: [Select]
public ThisIsMyCustomNamespace.EasyMovieTexture easyMovieTextureComponent;
What you'd be doing here is, you'd take the namespace and look in it for the correct variable type.
With this, you would no longer have to use the additional "using XXX".

2) This is a tad more advanced :
Code: [Select]
using EasyMovieTexture = ThisIsMyCustomNamespace.EasyMovieTexture;
This is a very powerful other use of "using". You can tell Unity to replace any word in your script with another one before analysing/compiling the script.

This way, each time you write EasyMovieTexture, Unity will actually receive it as ThisIsMyCustomNamespace.EasyMovieTexture. You can do this with anything, including long namespaces. For example, if you had a namespace with a very long name, you could be lazy and replace it with a short one. Like this:

using vlnspc = VeryLongNameSpaceWellNowItsJustSixLettersLong;

Obviously this can save you a lot of typing when you use it a lot in your script.

And that's it. I know it's a lot, which is why you just need to know that adding the "using" directive at the top of your script will suffice in your case. Unity will tell you when this doesn't work, but it doesn't happen very often. That should take care of all.

Now lastly, let's have a look at why your previous script didn't work. What Unity actually means by " An object reference is required to access non-static member 'MediaPlayerCtrl.GetSeekPostion()' " is that Unity needs some "spawned object" (an instance) to use the function.

Let's have a real-use example. What are GameObjects? Well, just like pretty much everything else in programming, they are classes. Now, imagine you went and asked Unity what the position of GameObject is:
Code: [Select]
GameObject.Transform.position;Obviously, Unity can't give you a proper answer, because there may be a thousand GameObjects in the scene, or none. Which do you mean?
This is why in this case, you would always declare a GameObject public variable in your script, where people or other scripts can plugin a "spawned"(instanced) GameObject:
Code: [Select]
public GameObject go;
...
go.Transform.position;
Now you can compare your initial action with the one here and see that you did not use an instance. That is all you seem to have done wrong.

There are also cases where you do not need an instance. They are called static functions/classes/variables. An example of a static function would be
Code: [Select]
GameObject.CreatePrimitive(PrimitiveType.Plane);Since this creates a new GameObject, it does not need anything from any other GameObject. Therefore it can be static.

Also, do not hesitate to ask lots of questions. Programming is a huge discipline with a very specific vocabulary. No one who just started learning it can google his questions.

9
Share New Actions / Re: A* pathfinding (stable 0v841)
« on: November 28, 2013, 06:49:07 AM »
If the newer version does not fix it (which tbh I don't think it will), please send me an example scene. Everything you send to my mail address will be seen as confidential material, I won't share any kind of info about your project with anyone else, so no worries there.
From the sound of it , it  might be a bug or it might be a bad setup. I can't judge it without an example.

10
Share New Actions / Re: A* pathfinding (stable 0v841)
« on: November 03, 2013, 05:35:51 AM »
I prefer working via the forums. The examples were always broken, it's some weird library thing, I'm not sure if it'll work if I fix them, but I'll try it tomorrow anyways, it shouldn't be too much work.

Btw, would it be possible to give me full git rights while still retaining yours? Like, I would like to push to the real repo directly without having to go through all this fuss about pull requests etc, but I imagine it would be for the better if you could still manage it because I don't really have any clue whatsoever about what I would have to do as owner of the repo :D

EDIT : Oh and changing the classnames is a very good idea, it always enfuriated me when I tried to reference a type and only later when I compiled the script I find out that for some reason it didn't start with a capital letter :( As for the Mohogony() and DoStuff() functions... yeah that's me alright :D

11
Share New Actions / Re: A* pathfinding (stable 0v841)
« on: November 01, 2013, 04:50:49 PM »
this is the reason why I never used git before... I just can't make it work. I got as far as committing it succesfully and seeing my commited changes etc, but when I want to push it it either can't find the server (in https) or it says I have insufficient permissions (ssh). It's enfuriating how I never seem to get the hang of it :S . Well anyways, I put the changes in the zip file. Just extract it in the FsmPathfinding folder and override the scripts there.

12
Share New Actions / Re: A* pathfinding (stable 0v841)
« on: November 01, 2013, 11:44:34 AM »
ok, I commited it, and I think I pushed it but I'm not sure. If I didn't send a push request then I don't understand how you would do it with the github program...

13
Share New Actions / Re: A* pathfinding (stable 0v841)
« on: November 01, 2013, 10:34:05 AM »
ok, I'll just put my changelogs here :
- Added default values for moveTo properties;{moveTo}
- Added the override keyword to the actions, without it they won't start;{moveTo,addNodeConnection,ComplexPointGraphFromChildren,createNodes,createPathTo,duplicatePath,getAStarPathInfo,getClosestPointOnPath,getGraphInfo,getGraphInGraphs,getNearestNode,getNodeFromNodes,getNodeInfo,getPathInfo,nodeContainsConnection,PointGraphFromChildren,recyclePath,setAStarPathInfo,setGraphInfo,setNodeInfo,setPathInfo,smoothPath,translatePath}
- Changed the name of the Path-Parameter in OnPathComplete to path1 so it won't locally replace the private variable "path", and cause it to be inaccessible anywhere outside of the OnPathComplete function; {moveTo}

With these changes the moveTo action now works.

14
Share New Actions / Re: A* pathfinding (stable 0v841)
« on: November 01, 2013, 10:23:51 AM »
I couldn't start it before (unity just wouldn't load the project, the Unity.exe process just stopped without any kind of warning or error message :S ) So now I created an empty project and pasted the stuff inside, and now it works. So far I've only noticed that you had dismissed the default values for the moveTo action. However, those for the finishDistance etc are very important for newcomers. A year ago when this started I also just used 0 for all settings as a default and people complained :D Apart from that it seems to work fine though. I'll try to push my changes this evening, never really worked with git though, so it might not work :D

Edit: It won't move, but I might just have made some mistakes myself, I'm looking into it :)

15
Share New Actions / Re: A* pathfinding (stable 0v841)
« on: October 28, 2013, 02:07:59 AM »
examples don't work because the AstarPath component and therefore all graph settings are lost on export. My idea for the future was to put both the Assets/... data and the Library/... data as they are into the installer. Then the installer could put everything in its' right place and no data should be lost. I never got around to testing this though.

Pages: [1] 2 3 ... 34