playMaker

Author Topic: Need Some Help With Animations (IM NEW)  (Read 1819 times)

SinistarPlays

  • Playmaker Newbie
  • *
  • Posts: 4
Need Some Help With Animations (IM NEW)
« on: June 01, 2020, 10:41:52 PM »
Hey all,


So I'm new to unity, coding, and only just purchased PlayMaker yesterday -- after seeing how it looked quite simple compared to learning C# through YouTube tutorials and the promise of actually getting somewhere as wannabe solo developer.

Anyways, I acquired this purchased asset for a game I'd like to make as a first project that will probably be a 2D scroller of sorts, and the asset is titled "Character Creator 2D" which comes with their own set of animations once you create a character using this asset, giving you options to save the character as a prefab, json or png but I save the file as a prefab.

And mind you, when you completed and saved the character; it literally comes with multiple animated attack animations, idles, walking, jumping, tons of weapon attacks, running, tons more of variety.

So the question is how do I make these work now? I mean, I just want to understand as if I'm a toddler how to put them to work in the PlayMaker. To be able to string these already animated functions to work so I can actually move the character from A to B as a starting point.

Asset in question:
https://assetstore.unity.com/packages/2d/characters/character-creator-2d-111398

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Need Some Help With Animations (IM NEW)
« Reply #1 on: June 02, 2020, 01:47:10 AM »
Hi and welcome!

  I think you will need to learn Animator:  https://docs.unity3d.com/Manual/Animator.html

with this, you will be able to animate your 2d character, but first double check with the author of this asset you purchased, to check if he has a demo on these character being controlled by an animator controller.

Bye,

 Jean

SinistarPlays

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Need Some Help With Animations (IM NEW)
« Reply #2 on: June 02, 2020, 08:17:55 AM »
Hey Jean thanks for the reply,


I have checked through some stuff, and the guy has mentioned that it is up to the user to create their own character controller and to set everything up (aside from making them into animations) on our own.

Any ideas, is it something achievable through your asset playmaker? :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Need Some Help With Animations (IM NEW)
« Reply #3 on: June 03, 2020, 02:47:40 AM »
Hi,

 this will be solely done using Animator, which is provided by Unity:

this series are amazing:

 the author of your character setup asset, should at least have some ideas and direction as to how to use the final character being setup with that asset, how can you access the sprites making up the desired character, etc etc.

Bye,

 Jean


SinistarPlays

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Need Some Help With Animations (IM NEW)
« Reply #4 on: June 03, 2020, 09:01:38 AM »
thanks again for the second reply,

unfortunately that doesn't apply to my situation as thats animating, non pre-animated assets from scratch.


the character creator 2D when you create a character comes with animation already, its just that i don't quite know how to actually get them to work, for example i followed one of brackeys tutorials for simple 2d movement, i got that working, but the animation doesn't play when i "move" the object


therefore i am stuck, cause the animations work, but i just dont know how to attach them to function while i move left to simulate the walk animation.


when you create a character, it comes with a animator that has all the animation that works there, but what i am struggling with is how do i use either playmaker, or the animator from unity to get them to work properly while i move the character i created to simulate walking while he moves forward horizontally. :D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Need Some Help With Animations (IM NEW)
« Reply #5 on: June 03, 2020, 09:07:41 AM »
Hi,

 pre animated works with animator, you need to learn more about using animation within the Animator system.

but again, I think that you should ask more questions to the author of this asset, to give you directions, cause I can't really see why he would provide such system without a way to plug that into an animation system for actually moving your character around in your game.

 cc me to your email to him I can probably ask more technical questions, maybe he's confused by your query.


Bye,

 Jean
« Last Edit: June 04, 2020, 01:54:12 AM by jeanfabre »

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: Need Some Help With Animations (IM NEW)
« Reply #6 on: June 03, 2020, 05:48:16 PM »
When I understand you correctly, you want to know how you can move your character around and so that it also uses the animations.

When you begin something like this, try to first separate the visual appearance from the functionality. A good start is to setup a basic scene, with a floor to walk on, a box collider2D (I assume).

Make an empty game object. This is usually called the "Holder", and place it on the ground. The holder will contain the logic, and the character graphics will be dangling inside as a child object. Later.

It's recommended that 1 unit should be roughly 1 meter, or 1 tile. Toogle the grid on (button above the scene view, or [G]. Next, I recommend to make a folder for primitive sprites. Right click into it and create a square.

Drag the square into the scene, and into the Holder. Give it the proportions you want, for example 2 units high and 1 unit wide, and in the sprite renderer you can also set the colour. This thing will represent your character for quite a while. Also pick a nice background colour in the camera for good measure. I typically give it a "beak" with the triangle so that I know in which direction it's facing.

Add a box collider 2D, or a capsule2D and a rigidbody2D to the Holder. Freeze the rotation Z. When you hit play, the "character" (i.e. the rectangle) should be standing on the ground.

Next, you want it to move. Add an FSM, name it properly. In a typical first beginner setup you need these actions:

-- GetAxis with "Horizontal" (the exact name is listed in the Input Manager). Store the input. Multiply it with the desired move speed.

-- Set Velocity, and make sure to only set the x value from the input axis result.

(all of these are every frame!)

You should be able to move the object around, using physics. At least with the placeholder it should work. There are about 1001 other and better ways, but that should be a decent start to get it going.

I strongly encourage you to ignore the animated character for quite a while and get the movement logic and such to work nicely, and get something functional using just the primitive placeholder.

The tool in Unity for animation is called Mechanim. It's notoriously clunky to use. :)

But since you asked. Here's how you would generally proceed. For the Animation you then add also:

-- Set Float (every frame), and store a duplicate into a new Float Variable, which we'll use for the Animator.

-- Float Abs (every frame): this makes new float only go in a positive direction. I.e. when you idle, it's 0 otherwise it's some positive value.

-- Set Animator Float (every frame): this sends the new (Float Abs result) variable over to the Animator. It totally depends on how your asset does it. Probably it has an Animator on the "character" they provided? If so, you want to drag your character in where the placeholder is, and switch off the placeholder for now (but keep it for later prototyping). Then set this character object into the action, so it recognises that animator.

-- Head over to the Animator and make a parameter, e.g. "horizontal". Or check which ones are already provided. And use the same name as parameter in the  Set Animator Float action.
I generally avoid mechanim and use PlayMaker instead. To do this, I make use of a lot of blend trees that cut most of the clutter. For example, idle and movement can be done using one blendtree. The entire jump arc is one blend tree etc. I then use Animator Cross Fade action (from Ecosystem) to set specific animations I want. You have to see if you can butcher their setup, or maybe it's nicely organised.

In the traditional way, you have to make parameters in Mechanim (or find out which are there). Use the various Animator actions in PlayMaker to trigger, set bools etc to go to the correct animation state. Open the Actions browser and head to the Animator section to see what's available..

If that works. Tackle the flip. Add a float compare, and a set scale. Duplicate the entire state . Call one state "Facing Right" and one "Facing Left", each with an event "flip to left" and "flip to right" etc. The right one checks every frame if input is below -0.1, then go to other state. And the Facing Left if the input is above +0.1. In the Facing Left set the x scale to -1, and in the right one to 1. This should work as a first setup.

Once more, this should only get you going. Later you want to separate the logic into different FSMs, and there are better ways, but that then depends on what exactly you want to achieve :)
« Last Edit: June 03, 2020, 06:08:24 PM by Thore »

SinistarPlays

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Need Some Help With Animations (IM NEW)
« Reply #7 on: June 03, 2020, 11:04:51 PM »
Insane response :D  thank you both!


I will keep you updated and let you know of my results!

(And yes the character does complete with its own animator component attached to the "character" that has all the animations stored.

Here's a screenshot to give you an idea once the character is created as a prefab, and placed into the hierarchy, i have his components expanded and also playing his default idle that i want to use. from this point on that's where i was/am stuck

https://imgur.com/a/fkbHHCF

 (ofcourse, gonna try out what you said and keep you updated.)
« Last Edit: June 03, 2020, 11:08:22 PM by SinistarPlays »