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

Pages: [1] 2 3 ... 5
Share New Actions / SetParent Canvas Issue (and alternative action)
« on: September 22, 2018, 02:14:21 PM »

When using "Set Parent" on objects within the canvas, Unity will throw the error notification shown below. It still lets you play, but there are scaling issues.

Code: [Select]
Parent of RectTransform is being set with parent property. Consider using the SetParent method instead, with the worldPositionStays argument set to false. This will retain local orientation and scale rather than world orientation and scale, which can prevent common UI scaling issues.
HutongGames.PlayMaker.Actions.SetParent:OnEnter() (at Assets/PlayMaker/Actions/GameObject/SetParent.cs:38)
HutongGames.PlayMaker.FsmState:ActivateActions(Int32) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:205)
HutongGames.PlayMaker.FsmState:OnEnter() (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:175)
HutongGames.PlayMaker.Fsm:EnterState(FsmState) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2767)
HutongGames.PlayMaker.Fsm:SwitchState(FsmState) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2714)
HutongGames.PlayMaker.Fsm:UpdateStateChanges() (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2642)
HutongGames.PlayMaker.Fsm:Start() (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:1925)
PlayMakerFSM:Start() (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/PlayMakerFSM.cs:548)

Though I have no idea what I am doing, I somehow created an action using the suggested SetParent method which works and doesn't throw errors. I named it SetParent3 (there is already a second one in Ecosystem).

This action will do the (basic) trick, however, it currently has no other parameters (I have no clue how/what). If a regular wants to complete it, and upload it to ecosystem, you're super welcome. It would be best, I guess, when the default "Set Parent" works universally.


General Discussion / Re: Refund
« on: September 22, 2018, 10:25:31 AM »
To be honest i actually learned c# thanks to playmaker ;)

Same for me, though still in the early stages.

General Discussion / Re: Refund
« on: September 21, 2018, 09:23:55 AM »

Playmaker Help / Re: SetEventData + Enum?
« on: September 21, 2018, 02:02:39 AM »
thanks, I’ll check this out.

Share New Actions / Re: ColorMix
« on: September 21, 2018, 01:48:58 AM »
Hi djdino,

Thanks for the update, and adding it to ecosystem :)

Share New Actions / Re: Cinemachine Support [JULY 2018]
« on: September 20, 2018, 04:11:36 PM »
Perfect, thanks!

Share New Actions / ColorMix
« on: September 20, 2018, 03:56:06 PM »
Humble beginnings, part three. I made another tiny action.

You provide two colors, and a mix value (0.5 is 50% of each), and it returns you the resulting color, which you can store and use from there.

Use Case
You can tint sprites using the color field in the inspector. This action makes it possible for example to tint "just a bit" towards a second color, which is particularily useful when sprites use different tints, or when you want to change the amount of tint based on some gameplay parameter.

General Discussion / Re: Unity Sword man setup
« on: September 19, 2018, 04:00:07 PM »

Generally, you have to be more precise where you are stuck. :)

It seems your issue is with mecanim ("Animator" in Unity), not Playmaker. I recommend to look up documentation and tutorials for mechanim. I wasted many hours trying to figure out why the animation didn't play properly and it's usually one of the many settings that wasn’t correct. It also has many pitfalls.

In the Playmaker state when you execute the attack (after getting key down), "Set Animation Trigger" and feed in "attack" (case sensitive). That's the playmaker part regards animation.

In mechanim, add a parameter called "attack". So when Playmaker fires off "attack", the animation will go to the attacking clip.

In mechanim, connect the running state with the running attack, and set the condition to "attack" towards it. I.e. when the trigger is set off, it plays the attack clip. The transition back to running has an exit time, that’s the time from beginning to when you want to start to blend away. If you use "any state" make sure to untick the "can transition to self", which is another common pitfall.
As a tip, don't use keys, except you develop for certain web/PC platforms. It's generally better to use buttons, because they can be mapped in many ways for different inputs (keyboard, mouse, pads, controllers).

Playmaker Help / SetEventData + Enum?
« on: September 19, 2018, 09:47:28 AM »

I'd like to use SetEventData, which has all sorts of variable types in it, except for the enum. The critical part of the action is in the method, where all available types are listed.

Code: [Select]
               Fsm.EventData.BoolData = setBoolData.Value;
Fsm.EventData.IntData = setIntData.Value;
Fsm.EventData.FloatData = setFloatData.Value;
Fsm.EventData.Vector2Data = setVector2Data.Value;
Fsm.EventData.Vector3Data = setVector3Data.Value;
Fsm.EventData.StringData = setStringData.Value;
Fsm.EventData.GameObjectData = setGameObjectData.Value;
Fsm.EventData.RectData = setRectData.Value;
Fsm.EventData.QuaternionData = setQuaternionData.Value;
Fsm.EventData.ColorData = setColorData.Value;
Fsm.EventData.MaterialData = setMaterialData.Value;
Fsm.EventData.TextureData = setTextureData.Value;
Fsm.EventData.ObjectData = setObjectData.Value;

Fsm.EventData.EnumData is unknown, and I don't know how to declare enums in the fsm script. I'm aware that I can convert enums to something else, and then pass this on, but I'd like to keep things tidy and neat, if possible.

Can anyone help me with a bit of code that adds Fsm.EventData.EnumData to the Fsm script?

Playmaker Help / Re: Anyway of comparing float and use AND operator?
« on: September 16, 2018, 04:46:16 AM »
You can use 2 Float Compare and set the state in 'action sequence' (right click on empty space in the state window to select action sequence) ...

Amazing! I use Playmaker for quite a while and did not know about the Action Sequence functionality. Thanks a lot!

Need more accessible intermediary/advanced-level documentation :)

Playmaker Help / Re: Mecanim IK animations
« on: September 15, 2018, 04:57:05 AM »
I implemented something like this a while ago, albeit in 2D. Without any details what doesn't work in your case, here's a general overview how to do it.

Animator Layers
Normally, one animation clip runs at any one time, and mechanim blends between them as you tell it to do. The layers allow you to run several clips concurrently. A simple example: you have your animation of idle and running. But you want your character to blink the eyes every now and then. You could put the eye blinking into each idle and walking, but that would look unnatural and interfere with a clean walk cycle etc. As a solution, you'll use a new layer, set it to weight 1 (so it's in full effect), and make a clip with just the eye blinking periodically so it looks good. In this new layer, this blinking clip is simply the default state.

Once you got the concept, you have to think about how to slice the mustard. For example, for a weapon system, it could make sense to make an unarmed set, e.g. idle and walking with the arms swinging. But that looks bad with the weapon attached. So you have a a "just the arms" states for idle and running on a separate layer.

Generally, I found it best to not actually blend that much, but still take advantage of layers. Simply animate different parts, and delete everything from the clip that isn't necessary. E.g. in my example here, the eyes aren't animated at all anywhere else. So there is no weirdness from blending. Their animation is simply added.

Change Only Arm Movement
So you could make a new layer, "arms". Don't forget to set the weight to 1. You put an empty state in there as default, since when unarmed, you want nothing overriding the arm movement in the base layer.

Next, equip the character with the weapon (temporarily). If you have an unarmed state, or weapon switch system, you need an extra step. Let's do this first...

Bind Points
Generally, this works by another dedicated (empty) GameObject that serves as the bind/mount for the weapon. And a second one, that is the "grip" of the weapon.

Bind: You likely want to add the bind as a child object to the hand. Make it visble by giving it a small gizmo (inspector upper left corner). Leave it there.

Grip: Has the weapon a proper pivot, where it is held? If not, let's make one. Make another empty game object, the grip, also give it a tiny gizmo and put the weapon as a child into it. Move the weapon around so that the parent's gizmo is where the weapon is held by the hand. Rename the weapon so it's clear it's just an element and not the "the weapon" itself, and name the grip as "the weapon". This whole construction from now on is The Weapon. The point of the exersize is that when you drop it onto the character, and zero it, it'll sit correctly.

Now drop the weapon we just prepared into the bind, we also made a step earlier, i.e. the weapon is child of it. Important! Reset The Weapon's transform (i.e. zero position and rotation). Now, leave the weapon alone, and adjust the bind objectto orient and position such that it looks good.

You need to tweak a bit, but you want that the The Weapon itself (the grip with the weapon mesh) has a zero transform as child of the bind, while also making sure that the grip is at the correct place at the weapon, and the bind is properly in the hand. Make sure this all aligns properly.

Weapon Animations
Let's run through the process for idle. Copy over your idle keyframes to a fresh clip, or duplicate and rename it for the "idle armed" version. In it, only adjust the arm movement to what you want it to look like with the weapone equipped. After you're satisfied: In the animation timeline you see a list of game object that have been changed. Delete everything but the arms / IKs for arms. So you are left with an animation clip where only the arms move in some fashion.

This new clip goes onto the new "arms" layer in mechanim. Connect that to the empty state you created before, and set the conditions there, e.g. a trigger or a bool. First try switching around the idle and idle armed/blended animation and worry about the rest later. But with this method you can make a recoil animation etc. and it's independent of running and idling etc.

Prototype in Playmaker
Create a FSM, with two states. Each with a finished state leading to the next one. In the first state, listen for a "key down" and let's pick "tab", and copy this to the second state. Test this. Hit play. You should be able to tab between the states. We will be throwing this away later on, so it's not super important (use the "key" versions for prototyping, and button for real, because buttons can be mapped).

Now add the set animation actions accordingly into each state. One is for the armed version, one for the unarmed one. When you play, you should now see how the character's arms go from one version to the other, and you can switch back and forth using "tab". If you still have the weapon attached, you can see whether it looks good.

If that still doesn't do the trick, figure out what exactly doesn't work. Rather don't spent on another asset until you know what you're trying to solve.

Hope that helps, cheers.

Share New Actions / Sprite / SetOrderInLayer
« on: September 06, 2018, 04:38:13 PM »
Gets the SpriteRenderer of suitable GameObject, and sets the "Order in Layer" property to an integer you provide.

In 2D games with a camera set to orthographic projection, the Z axis is ignored. The layers are used to roughly sort what is background, foreground etc. But within those layers, you use order in layer to determine what is in front of something else. With this action, you can change that order.

In my case, a character carries a weapon on their back. When the weapon is drawn, it needs to change order in layer so it's drawn in front of the character.

Share New Actions / Re: ...just another big Custom Action collection (A-L)
« on: September 06, 2018, 04:05:29 PM »
Thanks for the actions! I also found a bug in one of them.

Bug: It works exactly once, then stops working. I suspect that it doesn't reset properly.

In the screenshot attached you see the setup. The top action is SendEventSetValue.cs and this produces the problem as described. The two lower actions do the same, but by conventional methods (which works). I only put them together to show the setup.

Hope that helps :)

Share New Actions / GetAxisRaw (Tighter, Snappier Input)
« on: August 29, 2018, 02:32:19 AM »
Hello :)

You feel that the movement of your character could be "snappier" or "tighter", especially for a platformer? Then you want to try out this action.

What it does.
The action is identical to GetAxis, but has a checkbox to switch to GetAxisRaw, also at runtime. This also gives you the ability to try out the difference as you play, which is good for prototyping.

A little bit of explanation
The typical way, Input.GetAxis gets the input from the player in a smooth way: assuming a controller with an analog stick, the axis value is smoothly cranked up to to 1 when you push right (-1 when left). Now, there is a twin called Input.GetAxisRaw, which does not smooth out the input. It's either hard left (-1) or hard right (1), with gives a snappier and tighter control, which might be more suitable for your game. You can also use the raw to calculate your own smoothing (see Unity's documentation linked to above).

Playmaker Tutorials / Re: how to make a timer and a basic turn system
« on: December 06, 2017, 04:35:47 PM »
Glad it's useful. Go ahead, and use this as you see fit. :)

Pages: [1] 2 3 ... 5