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 ... 8
Playmaker Help / Re: 2d weapon animation
« on: November 16, 2018, 03:50:19 PM »
For platformer, you have three general options:

— depending on what exactly is meant by “2D”. You can use full 3D, but use the same perspective and trappings like a 2D platformer, so it functionally is 2D, but is technically build in 3D. You can also mix and match. Use some sprites, or 2D tech (colliders etc) but on 3D models. Look for Romi Fauzi on YouTube.

— skeletal 2D, as Goner Games points out. This can be done in at least two ways: you can make body parts of a character and through rotation around pivots make it move (like a cardboard puppet). The parts themselve can be moved, or more conmon, a skeleton is animated, the bones are invisible, but the body parts are put as child underneath. The other technique is similar, but uses mesh deformation of a sprite attached to the bone rig. Unity has this in the works, I wouldn’t use Anima2D at this point. I myself use Puppet2D.

— Finally, classic frame animation technique, known as sprite animation, where the movement is drawn onto a series of images (sprites), as it’s done in cartoons and most older 2d games like Super Mario Bros, Megaman etc.

How the weapon animation works totally depends on which technique you use. I have such a system, and in my case, the skeletal 2d character has an empty game object as a mount/bind point at the hand, under which I can add a weapon so that when the weapon transform is zero, it fits exactly.

In playmaker, I send off a bool to the animator that the character is now armed. One way to do this is to have a complete movement set for armed and unarmed, and by condition (e.g. isArmed is true/false) switch using either one. But in my case, I also use animation layers, so that only hands and few animations are overwritten when the character is armed.

The procedure is similar when you go 3D, with bind points, and transition animations and conditions in mechanim.

When you use oldskool sprite animation, you must make all animations also with the weapon equipped (i.e. drawn onto the sprite) plus potential “switch” weapon animation clips. But you can also try to mix and match techniques. Then, as usual, the animations go into animation clips, equip_armed, equip_unarmed, idle_armed, idle_unarmed, jump_armed etc. And when some condition is met, you switch animation clips around typically in the mechanim animator. How to do this, study Unity’s 2D platformer project and watch tutorials.

Another method is to use a kind of singleton approach: have one “Game Manager” game object with an FSM that can store variables. Now everything of import can find the manager and store itself (or some other variable) into the game manager. This hinges on the fact that you know, and take for granted, that this game manager definitely exists in the scene, under a fixed name or tag, and thus can always be found, even if everything else changes dynamically. Now the wolf can get the reference from the Game Manager.

However, it many situations its better to keep parts self sufficient, i.e. make the wolf find player by tag, by name etc. You can also use a game object under the player to store a tag when you need the player holder to use a different tag. Then you find that child object, and then its parent etc.

Playmaker Help / Re: Creating a 2D "slinging" mechanic
« on: November 12, 2018, 11:45:11 AM »
The name of such mechanics is typically rope swinging of grappling hook. It can be done in a number of ways, each leading to a different behaviour. Typically, it’s done using joints. You can find dedicated scripts and tutorials on that.

A simpler method could be the “move towards action”. First, find the next latch point in viewing direction, store that latch game object, and then in the next state, move towards it. The graphical representstion (i.e. the “rope”) is often done with the line renderer component.

I tried a few versions, including with a distance joint, for which I made the action, but in the end used the move towards version (still to polish).

Found a bit here:

These were useful to me to understand the concepts:

Playmaker Help / Re: Sending values from a script to Playmaker
« on: November 10, 2018, 09:40:09 AM »
Maybe you can do it the other way around, let Playmaker get the variable, and if needed write into the Globals (probably not needed when you already have it in the script and can get it when needed. You can use Get Property, or probably better, add your own (simple) custom action.  To do this most conveniently, find the custom action wizard tool in the top menu under Playmaker, somewhere in there. MDotStrange in the forum and on YouTube has a simple good explanation on how to write such simple get/set variable actions for your purposes.

Btw, you can write if(aim), which is the same as if (aim == true). False is if (!aim). Also, you should use a bool for the aim as well, rather than 0/1 as off/on.

Playmaker Help / Re: Make bar go from 1 side to another? (Ex:HP bar)
« on: November 05, 2018, 04:36:29 AM »
When you approach a problem like this, first try out “dry” what needs to happen. For example, you could make a sprite with the bar. Set the pivot to the left side, then scale the x value and see what happens. You can then play around in the editor and get a feel for the values you would need for x scale. The bar could also be setup to be scale 100 right away (or done with a mesh or with an SVG sprite etc). If you cannot use the pivot, you get the same result by simply using an empty game object. Add a gizmo so you can see it, and then put as child the bar object underneath so that the empty parent is where the pivot is (i.e. left). When you scale the parent x, the bar should shrink and grow accordingly.

Next, you can start building the FSM that does the “slider pulling” in an automatic fashion, where you need to correspond the HP value to the x scale, i.e. 50 points is x scale 0.5 etc. To do this, use actions like float remap. You probably also need to convert the int to a float to drive the x scale.

Hope that helps,

Android Help / Re: Gamepad/controller right stick look around?
« on: November 01, 2018, 06:33:21 AM »
You can try having a parent and place in the camera.

Then make an state like the image below to do the rotation :


On the multiplier you can adjust the amount you want it to turn.
Also if you want the other direction you can add or remove the -

In the Input manager you can play around with the 'Gravity' and 'Sensitivity' to adjust how fast it turns.

Interesting that you split up into two set actions, is there a specific reason for this, or is this more convenience/symmetrical/consistent with the get axis action?

Playmaker Help / Re: How to make wave/sine movement?
« on: October 31, 2018, 02:58:21 PM »
Maybe a sideways “move towards” action between two waypoints (all three things child under one patent), with the easing function (I believe sine is there too). And a different, separate FSM, that moves the parent object forward. That way, the thing would describe a sine movement, or close enough.

Playmaker Help / Re: How to make a Jump Pad
« on: October 30, 2018, 12:42:55 PM »
I never use add force, it seems to require every frame or something for it says “continuously” in the documentation (I may be mistaken). Did you try add velocity? Did you check that the player game object is stored when entering the trigger? Go step by step. Debug and find out where exactly it is stuck (observe variables while playing etc).

If you use add force, you could try set it to every frame for testing. Then you can add a wait action in the same state to limit how much force is applied over time, e.g. say 2 seconds. If that does nothing, try velocity.

Playmaker Help / Re: How to make a Jump Pad
« on: October 30, 2018, 11:52:08 AM »
You could use physics materials and turn the bounciness up, this would however usually require that the character jumps on it. Right-click in project, create physics material, set values and then add it to the rigidbody (I believe).

Other than that, you may try a simpler setup first, to remove potential pitfalls. First get the trigger itself to work, i.e. you must set the collider to trigger, and use the correct actions, as well as correct components: rigidbody, colliders, and playmaker actions. If you use 2D, then all of these in their 2D versions, else, the standard ones (Unity was originally 3D only).

Next, remove a bit of complication and make a simple FSM and attach to player. First state listen to a key, get key down (tip as usual: in a real setup, you typically want to use button actions instead of keys, because they can be configured in input manager, but key down etc is good for initial setup and testing, as a kind of scaffolding). When the key is pressed, apply velocity upwards. Again, watch out, if you work in 2D, you need velocity2D and corresponding components.

If that works, you can tweak this easily, how much velocity, how high etc. Next, combine both. When the trigger is activated, you need to check that it registers the correct player object (with rigidbody on it, etc), and then simply copy over the state with the velocity that worked. Lastly, the makeshift FSM on the player can be deleted as the velocity is induced from the triggering object.

It’s always a good idea to break down the problem into simpler chunks and hook them up quickly, so you can test them rapidly, especially circumstantial designs (if player goes there, does this and that, then this and that needs to happen).

Hope that helps.

Playmaker Help / Re: Movement / Jumping
« on: October 30, 2018, 11:30:14 AM »
I use the same setup, with velocity horizontal on one FSM, and vertical/up on the other. That definitely works. Different solutions can have important implications later on.

Playmaker is up to date with current 2018 Unity versions.

Playmaker Help / Re: Why is my Int Add doubling my number???
« on: October 26, 2018, 03:22:26 PM »
When the FSM returns a loop error, it means that somehow your int test doesn’t work, and it goes through the roof (or cellar in your case). Check the exact order and especially check where in the action list the events are sent. Everyone has this (self made) bug eventually, where you scratch your head why it doesn’t work, only to find out that an action is never executed, because another action above it redirects to a next state.

Next, check global events. They can also jumble up the routine in a single FSM, e.g. when a transition is called Foo, and you forgot you used it, and you send event Foo in a broad way (not specifying the target FSM) — that’s why global events should always stand out (mine are ALLCAPS for example).

Next, check the sequence. Did you swap the formula around (b minus a, instead of a minus b)? Does a variable need to be reset with each loop, and you forgot that? When the actions are in one state, and must be executed in exact sequence, did you set the state to sequence (right click on state)? Otherwise, the actions merely start in order, but can finish at different times (and out of order).

If it is a simple FSM, and you cannot figure out what goes wrong, but you can make a new one and this somehow works; maybe it’s better to just throw the broken one away, and move on with the working version. It’s good trying to find out what exactly went wrong, up to a point. ;)

Sounds like that it is being calculated to local space of the previous parent, and when you move it around, it is still is considered part of another local space, and this causes the wonky behaviour. Just a guess.

Playmaker Help / Re: Level unlock
« on: October 22, 2018, 10:25:41 AM »
If they are linear, you could use a simple int counter, e.g. “progress”. At an appropriate moment, it checks how far the player got, and all levels lower and equal the counter are considered open. If you complete a level, just add +1 to progress.

If it is not linear, I’d use a list of bools, or enum flags.

Pages: [1] 2 3 ... 8