|
Post by invayne on Aug 30, 2014 21:47:05 GMT 1
alright sounds good man thanks
|
|
zax
New Member
Posts: 30
|
Post by zax on Sept 3, 2014 4:20:35 GMT 1
Well boss downloaded the update. And I will admit its much easier to set up use and manipulate. Sadly though still having the same two issues. The mouse cursor still jumps to center every time I click on something. And the cursor, while working on everything inside the inventory, still wont actually close the inventory. Nor does it work on the main menu screen or the stats screen. And that darned camera still wont freeze.
I am certain these are not issues with your inventory but issues with the UFPS framework somehow interfering with it. I am going to try and trouble shoot this over the next few days.
The camera issue is probably due to the fact I am using an FPS camera. I brought over the FSM scripts from your main camera to my FPS camera. But the camera still moves freely while the inventory is open.
The cursor issue is most likely due to how your hiding the cursor vs how the UFPS hides the cursor. I just need to find a way for the two systems to play nice.
What I did was copy your new demo scene then bring in my advanced player from the UFPS. The advanced player contains most everything in the UFPS system in one neat little package. I brought in nothing else to your demo scene but that character. But is controlled not by playmaker scripts but by a different kind of script. So somewhere in there lies the answer for both problems. I will keep working on it and let you know if I make any progress.
The new setup by the way is outstanding! Great work I really like it and am having no other issues with it at all. I like the new holders too very clever. They even work well with the FPS setup.
|
|
|
Post by Super Admin on Sept 3, 2014 5:44:07 GMT 1
HI Zax, thanks for these informations. I can explain in short about UFPS camera and why interfere with my system, first that FSM of a player contains some cursor options so each time you open something, inventory, menu, stats, workbench certain event will be sent to player, this is done because you can set proper animation for player and also when inventory is opened a mouse cursor is shown and i guess some scripts in UFPS have different approach that interfere with this. So you have to copy those states into your new player and that will prevent camera to move freely because player is set to rotate using camera rotation, and while GUI is opened that rotation will be disabled. Squarebite camera has only one FSM that will find player, get camera object to follow and it will follow it, nothing more and GUI camera only renders GUI layer so problem must be in those UFPS scripts. You can take camera script and just comment line that reset cursor or you can ask on their forum how to do that, maybe they can help. Cheers!!!
|
|
zax
New Member
Posts: 30
|
Post by zax on Sept 11, 2014 21:06:51 GMT 1
Ok good news everyone! I have solved the UFPS/Squarebite integration problems.
Below I have written step by step instructions for those wishing to integrate this awesome inventory with the UFPS frame work. Took me a few weeks to work out the bugs but we now have a working system.
First copy the Demo Example scene that comes with Squarebite as it has everything we need to begin. Select the scene and use Edit/duplicate (as copy and paste does not work for copying scenes in unity). Now rename your new scene and open it in unity.
Step 1: Setting up the player.
First drag the AdvancedPlayer (AP) from UFPS into your new scene. Now we need to drag a few things from Squarebite's player to our AP. rag the PlayerStats and CameraTarget into the AP. These are fine just the way they are so no adjustments needed just drop them in. Now drag the ObjectInteractionSystem (OIS) into your AP. Be VERY aware of your AP's camera field of view. You must place the OIS directly in the center of that field of view and raise it up a bit higher than it was on squarebites player. (a little less than half way up the fps pillbox) This may take some tweaking and minor adjustments to get it to act perfectly but it does work fine if centered properly. Next you need to copy the FSM playmaker script from the Squarebite player and add it to your AP. Do this by right clicking the red square on the script in your inspector and choose copy component. Then right click on any script in your AP in the inspector and choose "paste as new component". Now delete the Squarebite player from your scene and also delete the MainCamera as well. The UFPS AP has its own camera. And now your player is set up.
Step 2: Tweaking the UFPS Input Script
Now this took me weeks to find lol. But after TONS of trial and error I finally discovered why the mouse cursor acted all wanky when you opened the inventory. So here's the solution!
First select your AP and in the inspector about the third copmponent down you should see the vp_FPInput.cs script. Don't mess with the settings on this component! Right click and choose "Edit Script" Dpending on your editor its roughly about line 320 you will see this paragraph. Comment out the entire block like so:
That nasty little block of code was the source of all the cursor conflicts with Squarebite. Commenting it out makes the cursor work properly while the inventory is open. Now were almost done. Just one more script thing to tweak.
Step 3: Tweaking the Squarebite FSM playmaker script
Lets go back to that FSM you dropped into the AP. Click Edit to open it before you edit you will need to choose Edit INSTANCE (DO NOT EDIT PREFAB!!) This will edit the FSM only in this scene. Later you can go back and port it to the prefab if it works the way you want it to. But for testing lets stick to this scene. Now several things need to be done to each state. First uncheck every box in each state except the "set mouse cursor box" All the other boxes are not needed as they deal with the animation of a third person character. Also this eliminates certain camera conflicts as well. Do this for the following states only: Disable Mouse Enable Mouse Shop Opened Container Opened Stats Opened Workbench Opened
Do not touch the other states.
Now lets go back and look and Enable and Disable mouse states. To me the colors are backwards on these two so don't get confused. The red one labeled "Disable Mouse and Movement" is actually for when the inventory is opened. The green one Labeled Enable Mouse and Movement is for when the inventory is closed. I always use green for open red for close but hey whose nitpicking lol. You can actually change those colors if it makes it easier to remember... I did. Anyways, first look at Enable mouse and movement" Under set mouse cursor (which should be the only box checked now) make sure both hide cursor and lock cursor are both checked. If not check those boxes. Under the Disable state the hide and lock cursor boxes should NOT be checked. But still leave the set mouse cursor box checked. Now your cursor should work properly in all of the Squarebite GUI's.
As far as camera movement. Still working out a few bugs but I did find a sort of work around for freezing the FPS camera while in the inventory. Add the action "Scale Time" to both the enable and disable mouse states. Set the time scale in the disable sate to 0 (zero) and leave the enable state one set to 1 (one). What this does is effectively pause the game while in inventory. This works great for freezing the FPS camera while poking around your inventory. Unfortunately it does not work too well on the other states as they only have an open state but not a close one. So for example if you put one in the open chest state it will pause the action while looking at the chest but there is no state to add the un-pause action to. I will work on a fix for that. But I did notice disabling all the camera junk in those states did limit the camera movement to up and down it wont go side to side.
And that's it folks! You should now be able to play your UFPS character with full working use of the Squarebite inventory! YAY!!!
A few things I will be working on in the future:
Getting the health and energy bars to coincide with UFPS HUD
Getting UFPS weapons and items to appear in inventory. (UFPS has a hidden inventory)
Building an ammo bar Squarebite that displays the UFPS ammo count.
I'm not real good at doing tutorials so forgive me if that wasn't a perfect read. But I wanted t share all that with the community here. Hope that helps other people who want to use both systems.
Have fun Zax
|
|
zax
New Member
Posts: 30
|
Post by zax on Sept 11, 2014 21:17:02 GMT 1
One more addition to the setup of your Advanced Player.
You can add the entire folder of HOLDERS to your advanced player. Make sure to drop each holder into the fsm as well. This will allow you to "Equip" items just like you would with a third person character. Of course you wont actually see them in game but equipped items can change your stats so its good to have these holders in place.
|
|
|
Post by Super Admin on Sept 12, 2014 8:10:56 GMT 1
Hi Zax, wow this step by step guide is awesome for people who want to integrate those two systems together, you did a great job really, thanks for that. Theses days i was busy with working on my game that will have this system inside as well so other people will be able to see some example of Squarebite but i also want to integrate in future updates that 4.6 UI system that looks awesome, anyone tried new Unity UI system yet? Cheers!!!
|
|
zax
New Member
Posts: 30
|
Post by zax on Sept 12, 2014 13:40:55 GMT 1
Well hang on to the celebration for a bit still a few bugs to work out. For some reason once I save the scene it seems to ignore the FSM. And the cursor reverts. Basically the cursor lock and hide functions cease to work for some reason. I have an idea whats causing the problem. There is a command in the UFPS script mentioned above Screen.lockCursor = false; that is the culprit of all my problems I am sure of it. Commenting out the section above as I described prevents that command from resetting everytime you click the mouse which is good. Solved the problem of the cursor jumping back to center and resetting. The screen lock command in the UFPS script sets the cursor to hide and allows gunfire at the game start. In the enable and disable mouse states as I said I added that cursor control which SHOULD turn that off while inventory is open. And at first it worked. But for some reason when you save and close unity and come back in the values are still set the same way but unity ignores them. Only by deleting the FSM and re-dropping it in does it work again. This is most likely a bug of some sort.
I have an idea for a solution but need some expert advice.
What I need is to be able to send a command from the FSM to the UFPS script. Very simply I need the FSM to detect when the inventory (or any gui for that matter) is open on screen. Then I need the FSM to send a message to the UFPS script setting this variable to FALSE "Screen.lockCursor = false;" when a GUI is open and TRUE when gui is closed. FALSE locks the weapon from firing and displays the cursor on screen. TRUE enables the weapon fire again and hides the cursor. This would solve the entire dilemma. As I said the FSM version of lock cursor doesn't work its buggy at best. But setting this variable from the FSM I am almost positive would work.
So what I need bud is how to send that variable command from the FSM to the UFPS script? Im just learning playmaker so a bit confused on how to get it to talk to a script that is not an fsm? Im sure its a simple command somewhere but thought you might know how to do that.
Another option would be to set the variable inside the UFPS script itself. Sadly my programming skills are lacking. I know enough to be dangerous lol. Basically if I could write a simple line of code that said something along the lines of if GUI is open set that variable to false. If closed set to true. I tried writing that myself but it did not work so must be writing it wrong.
If you have ideas on either option I would appreciate it thanks. Ill keep working on it on my end too.
|
|
|
Post by Super Admin on Sept 12, 2014 14:28:50 GMT 1
If that is in script than yeah it is causing problem because in Playmaker we have action that do same thing but they override each other and that is why you get that bug. Best thing about Playmaker is that you can easy connect scripts with FSM components, you can send events, set variables or do anything easily from scripts using simple functions. I can write example to show you how to achieve that. To set parameters from FSM components to scripts you can use set / get property action that can access all global variables in your script, for example if that variable is boolean then you can just use set property, choose what property and set to true, or you can use get property to get that value, use boo test to check is it true or false and send event based on result. To invoke functions from script you just have to use action called Invoke Method, this action will call certain fuction on game object behaviour, that means if you have function on script that you want to call, you have to use Invoke Method to call function. Remember all values, variables or functions must be public, you can't invoke private function nor you can set private variable. Hope this will solve your problems mate Cheers!!!
|
|
zax
New Member
Posts: 30
|
Post by zax on Sept 13, 2014 2:58:20 GMT 1
Ok I can grasp that. So it IS a public Boolean. looks like this.. public bool ForceCursor = false;
set property action sounds like what I need to do. So I will try that.
Now just a few more questions my wise friend..
Can I write a simple state in the FSM that detects when ANY GUI menu is open? If I just make a new state in the FSM is there an action that detects when the gui's are open and when they are closed? If so I could make a state for the open and state for the closed and use the set property to change the force cursor bool to the correct state for each. Also do I have to link those states to anything else or can I just make them two stand alone states? If so this could be a very simple fix. Once we get this all ironed out Ill revise the tutorial above so everyone can use it.
Alternatively if I choose to write a function that would handle these when I call it up in FSM do I need to include the script name (Like you would when calling a function from another script?) or just the function name itself? Will playmaker find it just by the function name? Just curious for future use as I rally think your idea of set property will be the right answer here.
On a side note my new GUI skins are almost done. Looking very sharp. Ill share them with you when IM done. Making some very high tech sci fi ones using gimp brushes. Looking good so far.
By the way thanks for all your awesome advice and your hard work on this inventory. And thanks for your patience and instructions. Not many publishers out there go the extra mile like you do and I just wanted you to know that people like me REALLY appreciate all your hard work. This is what an indie community should be like. I really wanted to thank you.
|
|
zax
New Member
Posts: 30
|
Post by zax on Sept 13, 2014 4:27:17 GMT 1
Im such a pain I know but slight problem with the set property. I added set property. Selected the object as DCXPLAYER tried finding the force cursor public bool but it was not on the list. Also tried selecting the script itself as an object but no luck there either. Also tried get property, set object value and set bool value. Did not see my elusive bool anywhere. Also tried editing the instance instead of the prefab doing allthe steps above and still not on any of the lists.
Am I missing something?
|
|
|
Post by Super Admin on Sept 13, 2014 9:07:27 GMT 1
HI Zax, just woke up and couldn't respond earlier. Thanks for your kind words man So back to where we are, first to detect is GUI opened you can use few simple steps to solve that, no action that can detect GUI but you can public or local variables for that, for example like this: When you open inventory you can set local bool "InventoryOpened" = true in that state or you can use action SetFSMBool to set that value in FSM where you want to check is GUI opened. This is one value, you can do same thing for other GUI values as well and when you close that GUI just set bool value to false. In other FSM where you want to do checking you can use action that check if any bool is true or if all bool are false, set those bool variables and you are ready to go, or you can just use get fsm bool from any of those FSM and check each and send proper event. You can do this from script also, all you have to do is to get desired FSM and set proper variables in that FSM, if you need help with this i can write you example script for finding FSM using foreach loop. For that script that has public bool you can't detect there can be few issues, first you can't do that using find game object or so, you have to drag your game object, drag that script and then search for desired variable. To learn how to use set / get property just write simple script and test it out and you will find your problems, that is my way of learning things To call function using InvokeMethod you have to specify these things properly: Since it is based on drag and drop you can't set it on go using find game object, set property etc, you must drag values. Same goes for actions like Get / Set property. To make it functional and in game you have to specify all values before game starts and send proper events to set some values. Do you get clearer image of how things works here?
|
|
zax
New Member
Posts: 30
|
Post by zax on Sept 13, 2014 15:14:54 GMT 1
Yeah I get the concept but something I am doing must be wrong. I thought the envoke method might be easier so I tried it. I wrote two very simple functions in the script. One to turn on the cursor and one to turn it off. here is what I wrote in the script:
Now the Bazing function should enable the cursor on screen and Bazang should disable
So in the FSM I added envoke method to the Start State. Selected the correct script and my function was there. Set the function to Bazang. This should have shut off the cursor on level start. It does nothing.
Wasn't sure as to the modifiers in the function. So I tired different combinations. Public, protected and private, virtual, override, changed all of these in different combinations to see if that was blocking it from working but same results.
So it appears I am doing everything right but I must be missing something here. This is a simple function and a simple call from the FSM it should work. But it doesn't. Have any clue what I am missing?
Ill try the set property thing again. I did not know it would work on drag and drop only. I was wondering why it did not appear in the list. So Ill try that angle again. But this envoke method would be perfect if I could get it to work. Then I could put an envoke bazing in the Disable and enable mouse states in the FSM and it would solve everything. You think its in the way I wrote the function? Or something else I'm missing?
|
|
zax
New Member
Posts: 30
|
Post by zax on Sept 13, 2014 15:51:01 GMT 1
Ok as for the set property attempt. I dragged the object player into it and got that big list of properties unfortunately my public bool was not anywhere on that list. I tried dropping the script itself and the only thing on its property list was "hide flags" and "name". Sorry to be such a pain in the rump but I am doing everything your saying and I am beating my brains out over here trying to figure out why I cannot access one simple little boo.
Honestly I am convinced that the invoke method thing would be the best avenue if I can get it to actually work.
|
|
|
Post by Super Admin on Sept 13, 2014 16:14:49 GMT 1
Tested this out, use this basic script to test this out, in my case it works, don't see why it should't not Steps to test this, you can use empty scene to test invoke method: 1.Create empty game object 2.Attach this script to that game object MouseTest.cs (823 B) (download this script, click MouseTest) 3.Create FSM component 4.Set anything in that fsm that can trigger event, use wait for example 2 sec and send event to self to Turn ON Cursor. 5.In that state use invoke method and call bazing function and cursor will be on 6.Add other FSM to turn cursor OFF after few seconds and call function bazang using invoke method and cursor will be off This will turn off / on and lock / unlock cursor from Playmaker FSM and also you can watch in the inspector how your public bool variable reacts. What can cause your problem is that in PlaymakerGUI (automatic game object created on scene) has option to control MouseCursor, so try to turn that off in the inspector, here is the image where you can find that, just turn that off called Control Mouse Cursor: Try this and let me know was it helpful
|
|
zax
New Member
Posts: 30
|
Post by zax on Sept 13, 2014 18:49:42 GMT 1
Ok making progress.
Had to add the mouse test script to my DCX Player to get it to work right.
But mouse test was a success!
Created new FSM and called it FSM Cursor Control.
Added this new FSM to DCXPlayer.
On the start state of the new FSM I added Invoke Method.
Set this to mouse test script, and called the bazing function after a ten second delay.
Total success! At level start mouse was hidden and weapon could fire. After ten seconds weapon fire was disabled and cursor appeared. So perfect! So now we know your mouse test script works great! Does exactly what I wanted thank you.
Now here is the part I am stuck on. I tried adding this same invoke method to enable and disable mouse states in your original fsm. Nothing at all happened. Even tried the stats open one... same thing nothing happened. As if its not recognizing those states.
So here is what I need to do. In my NEW FSM Cursor Control (The one where I tested the invoke function with the delay which worked) what I would like to do (easiest thing I can think of) is to write a state that would detect when ANY GUI Menu (such as inventory, stats, container, shop and main menu) is OPEN Then use our new Invoke Method to call bazing. This should effectively give us the same result as the start delay one did whenever one of those menus are open. Problem is I don't know how to write that state to do that. And of course we will need another state that detects when those menus are closed and call the bazang to reset everything. If you could show me how to write those two states we could have this thing solved.
Thanks again for your patience and assistance.
|
|