Playmaker Forum

PlayMaker Help & Tips => PlayMaker Tutorials => Topic started by: cloud03 on December 03, 2013, 07:31:29 PM

Title: 2D Physics Based Platformer Tutorial
Post by: cloud03 on December 03, 2013, 07:31:29 PM
[UPDATE, 05/16/2014] New Episodes for the 2.5D Series, which is part 9 cover Deploying onto Android Device.

Hi guys, I've just uploaded a physics based platform setup tutorial purely using playmaker, here is the link:

Part 1 - Basic Movement:

Part 2 - Moving Platform:

Part 3 - Ledge Grab and Climb:

Part 4 - Converting to Mecanim:

Part 4a - Mecanim Tweaks:

Part 5 - Rope Swing:

Part 6 - Ladder System:

Part 7 - Weapon System:

Part 8 - Adding Enemy:

Part 9 - Android Deployment:


2D Sprite Based Platformer:

Part 1 - Basic Movement

Part 2 - One Way and Moving Platform


PS:English is not my native language, so please excuse if there any part that are unclear, you can just comment and I will reply ASAP, or maybe discuss it here...
Title: Re: 2D Physics Based Platformer Tutorial
Post by: jeanfabre on December 04, 2013, 05:03:03 AM
Hi,

 This is very much welcomed!! thanks for this.

It would be good you share the project too, that will help people relate to what you are saying and see it in unity as well, it's very important. Also so that they can compare with their own attempt later, and prevent the typical ( it doesn't work, tho I did exactly like how you said :) )


Bye,

 Jean
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on December 06, 2013, 03:23:40 AM
thanks for the feedback jean...

I've sent you a PM regarding sharing the project files, could you check it?

Thanks
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on December 11, 2013, 05:07:49 AM
updated, just added the 2nd part, which deals moving platform... :)
Title: Re: 2D Physics Based Platformer Tutorial
Post by: jeanfabre on December 11, 2013, 02:24:18 PM
Hi,

 can you bump me next week on this? thanks :)

bye,

 Jean
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on December 21, 2013, 10:11:47 AM
Hi Jean, I've sent you a private message regarding your suggestion for sharing project files, could you check it? Thanks
Title: Re: 2D Physics Based Platformer Tutorial
Post by: jeanfabre on December 26, 2013, 09:24:23 AM
Hi,

 I have nothing in my pm inbox coming from Cloud03, can you send me your message again? thanks,

 Bye,

 Jean
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on December 26, 2013, 10:16:48 AM
I've sent it to your mail by mistake....please check it, thanks
Title: Re: 2D Physics Based Platformer Tutorial
Post by: parallel on December 26, 2013, 12:46:22 PM
Excellent, really helpful tutorials cloud03.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: jeanfabre on December 27, 2013, 05:48:45 AM
Hi,

 yes, received. As far as packaging. You should not put the PlayMaker Folder at all iny our package, that will be the best approach.

So you should create a single top level folder with all your assets in there and package that folder only.

If in doubt simply send me packages and I'll validate them.

Bye,

 Jean
Title: Re: 2D Physics Based Platformer Tutorial
Post by: parallel on December 27, 2013, 03:36:08 PM
I haven't had any real success with physics and characters before so have avoided that so far, so your tutorial is a good starting point. I have a question that may be better suited in the unity forums 'absolute 101', but anyways; why does my character, after having set up rigidbody and capsule collider with the getAxis+setVelocity, tip over on the capsule colider? pressing left or right will initially just tip him one way or the other on the capsule coliders axis until the bot is flat on the floor and then you can drag him either way lying down, what am I missing?

Edit: I had frozen the wrong axis  ::)
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on December 27, 2013, 08:25:47 PM
Hahaha that is also happens to me when I first trying to create this...glad you got this sorted...

I'm in the middle of creating the next lesson on adding rope jump, and hang on the ledge, hopefully I can release it soon....
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on January 07, 2014, 06:50:20 AM
Hi guys, finally got the time to finish the third series of the tutorial, which covers ledge grabbing and climbing...so enjoy guys!

Feel free to ask if there is any part that are unclear..cheers
Title: Re: 2D Physics Based Platformer Tutorial
Post by: KomalR on January 24, 2014, 10:23:36 AM
This is really great. I've been looking for this kind of tutorial, in the end you'll get a sorta finished game, type. All I've been getting are bits of tutorial that are not carried onto the next video. They are great but doesn't help a noob like me.. :p

Anyway, looking forward to the next part.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: softreset on February 02, 2014, 05:18:28 AM
Hi Jean, I've sent you a private message regarding your suggestion for sharing project files, could you check it? Thanks
Is there any project files? Sorry, I don't see any, althought tutorial is self explanatory and very wll done, thanks for sharing your knowledge.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on February 02, 2014, 09:35:42 AM
I've forget to upload the project files, just uploaded it now, and here is the link:

www.romifauzi.com/files/2DPhysicsPlatformerProjectFiles.unitypackage

Just import it to a new project with playmaker imported before (and the custom camera action I've included on the youtube video description)...

Glad to hear the tutorial is understand-able .. :)
Title: Re: 2D Physics Based Platformer Tutorial
Post by: Meathead on February 03, 2014, 10:34:29 AM
Would be cool, if you could do this with mobile :)
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on February 03, 2014, 08:53:28 PM
It is quite fast actually in mobile, I have tested it, and with the current tutorial, you can simply change the input, by creating a GUI for controls, and make that GUI to change the horizontalAxis and verticalAxis variable accordingly, and then disable the get axis action....that should worked...

Hopefull I can do the tutorial how to make it mobile soon....
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on July 24, 2014, 06:49:24 PM
updated part 4th, which dealing with mecanim. cheers :)
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on August 07, 2014, 10:36:14 PM
Another update, please check the first thread... :)
Title: Re: 2D Physics Based Platformer Tutorial
Post by: MS80 on August 10, 2014, 02:14:27 PM
Thank you very much! Your tutorials are really impressive and useful, very well done, exactly what I was searching for!

Do you think it would be possible to attach updated project files (with mecanim)?

Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on August 12, 2014, 11:07:41 AM
Thanks a lot for the kind words...Guess I forgot to include the updated project package.., well here it is:

http://www.romifauzi.com/files/2DPhysicsPlatformerProjectFiles_mecanim.unitypackage

Hopefully it'll help :)
Title: Re: 2D Physics Based Platformer Tutorial
Post by: MS80 on August 14, 2014, 06:47:32 AM
Thanks, this helps!

Looking forward for rope / ladder tutorial  ;)
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on August 28, 2014, 01:48:05 PM
Bump, uploaded a new tutorial episode, basically for doing 2D Sprite Base Platformer, and I've decided to start from the beginning for this one to make it more simpler and clearer, and I've also do couple of things differently that is also applicable to the 2.5D one...

hope you all enjoy the tutorial, cheers! :)
Title: Re: 2D Physics Based Platformer Tutorial
Post by: darekk on September 01, 2014, 05:12:39 AM
Thanks a lot !!!
I'm waiting for this 2d sprite tutorial long time   :).
Greetings
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on September 02, 2014, 11:42:49 PM
@darekk: thanks a lot

Uploaded a new episodes, please check the first post... :)
Title: Re: 2D Physics Based Platformer Tutorial
Post by: dzyothwrld on September 23, 2014, 12:47:57 PM
I think it would be much better if you explained more about why you do the things you do in your videos. Right now you mainly just show people what parameters to put and what actions to use and stuff, but you don't really explain much why and how it works. So basically I'm learning what to do, but not why and how it works. Just some constructive feedback for you. Other than that, your videos are great.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on September 23, 2014, 08:37:50 PM
dzyothwrld: thanks a lot for the feedback, I'll keep that in mind on future tutorials. Cheers!
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on October 21, 2014, 07:08:34 AM
Update: New Episodes for the 2.5D Series, which is part 5 covers rope swing, check the first post....
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 14, 2014, 01:06:13 PM
Just uploaded a new episodes, covers how to make a Ladder System, please check out the first post!
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 14, 2014, 03:49:02 PM
Newb question icloud03, how would 2D gameplay work on pre-unity 4.3 versions? I ask this because, when I was experimenting with playmaker plus the standard character motor, and platform controller scripts that unity provides, a issue would be the Z axis is enabled and my character would just fall off of a level.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 14, 2014, 06:49:02 PM
@coffeeANDsoda: do you mean 2D Gameplay with 3D objects pre 4.3? If its the case, I simply constraint the Z axis on rigidbody, and don't use the standard character motor, on these tutorials, I'm not using any standard script from unity, I build it with playmaker from scratch.
Or another way of doing it, if its not possible using constraint. Just add a invisible collider on each of the edge, and create a physics material, set the friction to 0 then assign the material to the invisible collider. This will make the character stay on the ground, and not fall off of a level.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 17, 2014, 05:17:56 PM
Invisible collider IE a boxed collider?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 17, 2014, 08:26:05 PM
yup, shape can be anything as long it is a collider, with no mesh renderer, so it is invisible and it will hold the character to stay on the ground
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 18, 2014, 12:04:39 AM
Right now, I'm having issues with other playmaker games that I am working on, so I'd like to dig into some of these 2.5D playmaker tutorials of yours to make a game using this type of perspective and reveal it.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 18, 2014, 03:42:03 AM
Sure! let me know if its already available then, can't wait to see it :)
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 18, 2014, 05:56:37 PM
Isn't there a way to do animation without mecanim? Because I thought about using other means or just go with a static image for now.

Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 18, 2014, 08:56:22 PM
You can use the legacy one, but you won't be able to use sprite animation, if it is a 2d game, and you use some sort of ik for the 2d character (with splitted body parts, and parented inside unity, then animated), you can use legacy animation, there is a thread regarding this.

But I'm all about mecanim right now, for me it is really good, and once you grasp the concept behind it, there is nothing you can not do literally with mecanim. For me there is no reason to not use mecanim, and I don't think I'm gonna go back with legacy again...Is there any difficulties for you with mecanim system?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 18, 2014, 09:32:14 PM
I'd just like to know what other alternatives are out there.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 19, 2014, 09:31:34 PM
Plus, I'd like to set up a jumping system by adding another FSM without parenting another object in order to make the player land naturally.  Can't I add force on another state with a negative value of force, since if my character is going to jump, I'd have to use the Y axis.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 19, 2014, 10:37:59 PM
What kind of jump do you want to achieve?

If you mean with parenting another object is the groundDetect, you can use raycast for ground detecting, that will eliminate the needs of a trigger object such as groundDetect.

Of course you can add "add force" to another state with negative value, I'm not sure though with what you are trying to achieve by this, could you elaborate more?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 19, 2014, 10:42:06 PM
What kind of jump do you want to achieve?

A type of jump that applies for an area with normal gravity which includes 2 FSM's on one object(the player). Basically I want my character to jump normally.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 20, 2014, 02:22:54 AM
Well, the jump part of the tutorial is actually quite normal, it is using unity physics, so gravity automatically takes into account.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 20, 2014, 02:39:07 AM
Though it still acts like the player is jumping on the moon.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 20, 2014, 06:50:26 AM
well in that case, you can increase the mass of the character, to make it heavier, so it will feel more realistic, just try fiddling the mass character, and the jump force to get the best feel you're looking for...
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 20, 2014, 08:36:43 PM
well in that case, you can increase the mass of the character, to make it heavier, so it will feel more realistic, just try fiddling the mass character, and the jump force to get the best feel you're looking for...

When I increase mass on my character it doesn't really jump. Isn't there an action that temporarily increases mass when the player lands?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 20, 2014, 08:47:58 PM
well you can set the rigidbody property while on air, and change the mass value...but it would be simpler if you just adjust the add force for jumping value, the default amount is 250, so if you increase the mass of the character, you will also have to increase the jump force.....but the gravity will be the same, so by changing both of those value, you still can jump high or low, and fall or lands quickly because of the higher mass...
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 20, 2014, 08:54:31 PM
Just feel that when I set jump force, it's like no matter the amount, it doesn't feel as responsive as add force landing for forcing the player down. It's like theirs a delay or lag when the player jumps.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 20, 2014, 08:57:05 PM
well in that case, you can modify the jump to tailor your needs, adding force while falling, or changing the mass temporarily while falling might be a solution.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 20, 2014, 09:02:05 PM
How would rigidbody mass be modified though if I had to use an action in order to achieve that? I can't use a force mode besides force, then it acts like the player is launched like a rocket out of control.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 20, 2014, 09:05:09 PM
under jump state, after user press jump button, and add force action executed, drag the rigidbody component to that state and choose set property instead of get property, change the rolldown menu properties to mass (or something about mass), and a float input should be available, and change it to any amount you want, please refer to a set property action regarding this.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 20, 2014, 09:14:28 PM
Drag rigidbody component? So in add force, I would switch it to Specify Game Object?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 20, 2014, 09:20:37 PM
the idea is changing the character rigidbody mass on runtime via playmaker states, and in order to do that, you'll have to use set property action. Set property action can modify any property from a component, for clearer explanation please refer to this tutorial:
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 20, 2014, 10:28:58 PM
I see. It's working a lot better now. More responsive, however, when I set up a few platform cubes up, when I fall off of them, it acts like it's floating around in the air until a press space. Isn't there a way to resolve this issue like detection without another object on the button of the player to check whether or not theirs anything to detect?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 20, 2014, 10:59:50 PM
Well instead using a trigger object for detecting ground, you can use raycast, I've uploaded a video tutorial on how to do that, but instead using raycast 2d like in the video, use raycast (without 2d) for 3d objects. Check the video on the first page, the first part of 2D Sprite Platformer series..
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 21, 2014, 02:56:20 AM
Well instead using a trigger object for detecting ground, you can use raycast, I've uploaded a video tutorial on how to do that, but instead using raycast 2d like in the video, use raycast (without 2d) for 3d objects.

Did add the standard raycasting actions for the states, and added a ground tag to the platforms and ground. Still get the same results.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 21, 2014, 09:31:31 AM
Can you send me your stripped down project? I'll take a look if you want...
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 21, 2014, 02:58:34 PM
This is what I have for the scene.

https://db.tt/2T854oY9 (https://db.tt/2T854oY9)

https://db.tt/NYv3jxfC

https://db.tt/8ldFBcYV

https://db.tt/ny2MLkTD

https://db.tt/wja8P6qg

https://db.tt/CuSsyPiP

https://db.tt/lcO7QMGc

https://db.tt/uKnyJZmw

https://db.tt/DUDJpaIb
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 23, 2014, 04:18:49 AM
Under raycast check, I think the wait action time is too long, perhaps set it to 0.1 or 0.2 should smooth things out...
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 23, 2014, 05:10:03 AM
Tried that, still get the same results. What about adding raycast and everything else to the first state?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 24, 2014, 09:26:55 AM
Maybe that will do, put raycast after button jump pressed...
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 24, 2014, 02:09:32 PM
Maybe that will do, put raycast after button jump pressed...

Along with Set Game Object? Therefore the actions would work like following top to bottom?

1st: Get Button Down

2nd: Set Game Object

3rd: Raycast

4th: Game Object Compare Tag

I thought about this because actions act differently when you have position them in a different way.



Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 24, 2014, 10:34:50 PM
Tried having the states like that in order and I still can't get raycast to work properly. Here's the project, even though it's bigger than it should be.

https://db.tt/g7wmqQQo
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 25, 2014, 03:27:58 AM
Well, after checking your scene, the most basic problems lies on your scene scale, your object scale relative to scene is very big, for example the 2d player has a 12 units scale on every axis, and the ground is also so big.

I'd change the scale for the sake of tidiness (scale everything back to one, and then scale the ground accordingly), but if its too much of a hassle, you can change the gravity value under physics setting (under project settings)...

here is the scene I've modified, just put it inside your asset folder, and then open it up, also change your gravity value, because that setting depends on the project,  I've change it here, but yours may stay the same, so you'll have to do that also, I
ve set it to -250, and it is all good...

PS: I've created a new FSM for jumping, and disabled yours (but not deleted it)
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 25, 2014, 03:49:29 AM

PS: I've created a new FSM for jumping, and disabled yours (but not deleted it)

Would the scale of each object contribute to the player being unable to move around? Because I can't move my character.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 25, 2014, 04:03:14 AM
It is working fine here on my end, one thing please make sure the variable for moving stored on get Axis, and set velocity, because it was reseted to none when I first imported your scene, so I have to set the horizontalAxis again....
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 25, 2014, 04:24:17 AM
Which for Get Axis? The global variable or local variable you made?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 25, 2014, 04:36:58 AM
On your FSM, set the get axis variable again, it can be global or local, as long it stores the get axis variable, and then feed it back to set velocity action on the x axis...
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 25, 2014, 04:58:13 AM
What about deleting it and adding the action again? Because for some reason, it's not responding at all.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 25, 2014, 05:05:23 AM
You can try that, it should be working though...
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 25, 2014, 03:30:13 PM
For set velocity, it wouldn't respond to input, but when I used that variable on the X axis option, it did work. However, gravity and the player getting stuck on tagged objects when pressing jump still remains a big issue. A day ago, I just used add force in the opposite direction, while it did help the moon gravity problem, still a big issue is getting stuck on other object it would collide with and the player having the option to jump again in air when you try to fall off of a platform.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 25, 2014, 08:48:21 PM
I've uploaded the whole project in a clean new project, and setting it accordingly, here is the link:

https://www.sendspace.com/file/j4frmy
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 25, 2014, 08:57:08 PM
Does it work with the version of unity I'm using? I'm using 4.2.2 Because it saids it's not compatible and if I open it that it would risk data loss.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 25, 2014, 08:59:55 PM
I'm using 4.3.4, so you will have to upgrade your Unity...
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 25, 2014, 09:30:52 PM
Is there anything in the project that would prevent it from running in my version? Or would that I would have to go through all my other projects and back them up somehow?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 25, 2014, 09:33:46 PM
You can just try to open it on 4.2.2, if its not working, then upgrade the Unity.

I would also recommend to back any other project into a zip, so if something went wrong, you can extract it again from the zip files...
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 26, 2014, 02:47:30 PM
On your end, how do you feel about how jumping reacts? Because when I get to other platforms it doesn't feel as responsive as the first platform and even those objects are tagged.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 27, 2014, 04:25:36 AM
On my end it feels fine for me, no difference on the jumping effects..
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 27, 2014, 04:31:25 AM
What about touching a end of a platform or side that's like a wall? Because when I do that when I fall off of one, when I press space, it stops or acts like it's stuck.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 27, 2014, 09:24:54 PM
Plus, when I set up the FSM the way that you did for jumping it doesn't respond until I connected to the states that were like yours like 40 times. But when the raycast down state with a jump transition flowing into the Jump now state it has the low gravity affect. I think this isn't normal because I also recall that your projects FSM only gave the player the ability to jump once, and for some reason that isn't the case for mine.

In terms of how the players rigidbody is set up, since I made it a bit smaller then yours. It's set up this way.

The players scale on Transform is following.

X Y and Z = 1.8

Players rigidbody

Mass = 3.1
Drag = 0.14
Angular Drag = 0.45
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 28, 2014, 01:10:15 AM
for when the player is on the edge, the problem is the raycast only start from the middle point, so it doesn't hit the ground, you'll have to add another raycast from the edge of the bounding box of the player with direction also down to detect this, you can search tutorial regarding raycast for this issue.

As for your FSM not working, I'm not sure what causing it. I've set it once and it worked right away, so there is must be something wrong going on, can you check my tutorial again, see if you missed a step?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 28, 2014, 01:24:00 AM
for when the player is on the edge, the problem is the raycast only start from the middle point, so it doesn't hit the ground, you'll have to add another raycast from the edge of the bounding box of the player with direction also down to detect this, you can search tutorial regarding raycast for this issue.


Don't understand. You added another raycast action in your modified version of my project? Don't think I spotted that unless you are talking about going back to your tutorial which did rely on a separate cube on the bottom of the character with another FSM. Like I said, I'm kind of confused because I am using the same actions as your project.


As for your FSM not working, I'm not sure what causing it. I've set it once and it worked right away, so there is must be something wrong going on, can you check my tutorial again, see if you missed a step?

If I'm not mistaken the project that you uploaded seems to differ from your tutorial series. I recall that you added a global variable as well as making a transition global on another FSM.

Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 28, 2014, 05:45:52 AM
Don't understand. You added another raycast action in your modified version of my project? Don't think I spotted that unless you are talking about going back to your tutorial which did rely on a separate cube on the bottom of the character with another FSM. Like I said, I'm kind of confused because I am using the same actions as your project.


Nope, the one I've created indeed has a problem on the edge, and it is caused because on the edge, the raycast doesn't hit the ground, so to fix it, you'll have to add yourself another raycast but with a slight shifted origin on the x axis, so that one will still detect the ground when the player is on the edge, please refer to the 1st pic

If I'm not mistaken the project that you uploaded seems to differ from your tutorial series. I recall that you added a global variable as well as making a transition global on another FSM.

The basic system for the jumping is actually the same, the one in the tutorial and the project, the same theory applies, regarding global variable, I'm not quite sure what you meant with it? the one that using raycast does not need global variable at all to jump, local will do.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 28, 2014, 03:43:11 PM
In the first part of the 2d sprite platform tutorial? I thought in Part 1 when you covered raycasting you made a transition(Do Jump, On Ground) global to work in two FSMs all at the same time.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on November 28, 2014, 06:05:39 PM
Can you check it again:
I'm sorry I cannot help you further, cause I don't know what makes it doesn't work on your end, everything running fine here, although for the raycast on the edge you'll have to try adding yourself, but the concept just like the picture I've attached before...
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on November 28, 2014, 06:13:22 PM
I will take a second look at it. I could be mistaken with the first series of tutorial videos that you covered regarding a 2.5D environment instead of full 2D like you just posted above.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on December 01, 2014, 08:45:33 PM
When I set up the movement the way that you do in your 2d sprite tutorial, along with just a rigidbody and capsule collider, the keys go in the opposite direction compared to what value of X is on both flipping states?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on December 02, 2014, 07:19:21 AM
The flipping method are not meant for the 3D version, it is used for the sprite version, so for rotating character, better use the look at method (the 2.5D tutorials, not the sprite ones). As for the jumping system, raycast actually will be better than using a trigger object as the ground detector, so better only to adapt the jump system using raycast, and leave the other system like described from the tutorial.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on December 05, 2014, 09:54:30 PM
Watched the 2.5D tutorial up till you went into animation, and while falling is more responsive now on my end, I still have the player sticking on to tagged objects when I hit A or D keys when colliding. And jumping still looks like low gravity. When I use Get Property to increase mass, it's permanent? I want the mass to reset itself.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on December 07, 2014, 04:34:12 AM
Well you can change its mass when jumping, and upon landing, change the value back to normal, I think that'll do.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on December 07, 2014, 07:17:45 PM
Well you can change its mass when jumping, and upon landing, change the value back to normal, I think that'll do.

By just setting Get Property, and adding another one at the first state?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on December 07, 2014, 11:22:42 PM
You can try that, and see if its working or not...
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on December 08, 2014, 05:58:10 PM
How do I set up a boxed trigger to make the player respond back from a previous platform? I'm almost done with stage, but I want to have the player respawn so when they die, they don't have to refresh the web page allover again.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on December 20, 2014, 03:35:34 AM
Just FYI, this is what I currently have for the project for the raycast kill player issue. No matter what I do for this, I can't seem to get a death and respawn mechanic to work.

https://db.tt/nr0KdLsA

https://db.tt/gIHcYFh8

https://db.tt/3lj0JD8J

https://db.tt/4p88eNLd

https://db.tt/74mXlgrb

https://db.tt/GBgubjos

https://db.tt/PluYBZYQ
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on December 20, 2014, 08:41:14 PM
You can use triggers for this, position each triggers on each of the edge of the platforms, and when it gets triggered by the player, save its position to a vector3 variable, and if the player falls, set the player position back to that saved vector3 variable..
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on December 20, 2014, 08:53:07 PM
You can use triggers for this, position each triggers on each of the edge of the platforms, and when it gets triggered by the player, save its position to a vector3 variable, and if the player falls, set the player position back to that saved vector3 variable..

And if I set up respawn triggers on each platform or on some, would that vector3 variable be local or global? Plus what would that mean for the players death on the bottom dark colored trigger.

This is what I don't get, what actions would be needed like for after the trap destroys the player? Can't it be setting the position even for one single respawn?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on December 22, 2014, 09:48:06 PM
It would be easier to use global variable for the vector3, though I'd recommend use the local one, and send that variable between object.

Don't destroy the player, just set its position back to the last vector3 stored when the player triggers the last trigger are before he falls.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on December 23, 2014, 02:48:36 AM
It would be easier to use global variable for the vector3, though I'd recommend use the local one, and send that variable between object.

Don't destroy the player, just set its position back to the last vector3 stored when the player triggers the last trigger are before he falls.

Well destroying the player, that when it's act really weird on my end, like the players main camera is upside down. So even if I use a local vector3 variable, how could the triggers tell where the players position could go, whether it's the first respawn, second, third, and so on?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on December 23, 2014, 05:29:52 AM
Well that is why the player should not be destroyed, instead reposition it using the vector 3 value, and it is not the trigger who telling the player where it should respawn, but every time the player triggered the trigger object, store that trigger object position, and if the player falls, then reposition the player to that variable. The player will respawn exactly in the trigger position (the last trigger object the player triggered/encountered).
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on December 24, 2014, 03:57:35 PM
And this applies for one whole object that triggers death right?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on December 24, 2014, 11:19:00 PM
Well this is what I have right now for it.

https://db.tt/B22u2o6m
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on December 26, 2014, 08:07:38 AM
You should create separate trigger object each on the edge of the ground, and give it an action which store its position to a vector3 variable everytime a player trigger enter it. And use that variable to re position the player when it falls..
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on December 26, 2014, 03:40:13 PM
You should create separate trigger object each on the edge of the ground, and give it an action which store its position to a vector3 variable everytime a player trigger enter it. And use that variable to re position the player when it falls..

Therefore by using a vector3 variable it only works if it's a global?

By the way, as in the URL I posted above, do you notice that when the player collides with a wall it sticks instead of slips off of a object or wall?

How can this be fixed?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on December 26, 2014, 09:27:19 PM
vector3 variable can be global or local, but with local you'll have get or set the variable to transfer its value between FSM, as with global it will be easier, because you can use it right away between FSM, without the need for get or set variable actions.

For stucking issue, just simply create a physics material, and set its friction to 0 (both static and dynamic friction), and apply that material to the player collider component.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on December 27, 2014, 08:20:07 PM
For sticking issue, just simply create a physics material, and set its friction to 0 (both static and dynamic friction), and apply that material to the player collider component.

How come when I apply the material on the object it doesn't effect the player until I add the same one?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on December 28, 2014, 03:59:44 PM
Plus, when I set up the death trigger with a local vector3, what would that mean for sending a event to the respawn, since I would have to send a event with a game object specified right?

The issue I have here before setting up the respawn is it will only let me send the player to that spawn trigger if it has a global event. And I don't know if I should make a new FSM for the player since I don't know how that would work with the other scripts, after all the player doesn't have global events on either movement or jumping FSMs.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on December 28, 2014, 09:21:13 PM
For sticking issue, apply that material to the player, not to the ground or any other object.

And for respawn issue, I'd suggest to watch basic playmaker tutorial, and also tutorial dealing with variable and sending event. Most of the tutorial already covered basic concept for working between object, and it would be easier once you grasp the concept behind playmaker.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on December 28, 2014, 09:33:51 PM
What kind of basic tutorials are you referring to? Don't recall the basic game design series going into detail when a person applies similar concepts to a spawning system that spawns the player spending where that point or trigger is located, like a check point system or something. 
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on December 30, 2014, 02:32:14 AM
the one on hutonggames channel, and also basic logics behind programming, I found most of the unity introduction scripting are quite good. A bit scripting knowledge is useful when using Playmaker.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on December 30, 2014, 02:56:43 AM
If you were referring to global variables like in the puzzle quest tutorial on hutonggames channel, don't understand how this would apply to using a single instant death object being capable to trigger other objects that respawns the player if each them have different locations.

Just seems to me that it would make more sense if each spawn trigger had a different death collision object representing different positions, given that it wouldn't make sense to add the same value for X,Y,Z on a global variable. So if I used a vector3 with the position value on each axis it would have to be local.



Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on January 02, 2015, 04:41:26 PM
I could not get local vector3 variables to work properly, so instead, I made three point points that were globals and 3 separate death triggers.

Then theirs trying to get a handle on or figuring out how to make the player launch off of an object. But this is what I have for the prototype so far.

https://db.tt/6WuMWxGO

Curious about what your feedback is. Appreciate it.

Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on January 02, 2015, 10:22:42 PM
Here I've set a quick scene on how I'd do it,
 - I'm using separate spawn triggers on each of the edges.
 - Set them tags to SpawnPoint, and one big trigger below to detect if the player fall, upon triggering each spawnpoint, the player will store the x position value, under the Trigger Spawn Point FSM.
 - and upon falling, when the player trigger the death zone, the next state inside Death/Fall FSM will get the x position value from the Trigger Spawn FSM (I avoid as much as possible using global variable) and then set player position to that X value, with a fixed Y value, in this case 0.7, and 0 on the Z value. All the FSM are only on the player, the spawn point and death trigger does not have any FSM at all.

Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on January 02, 2015, 11:41:04 PM
How come it's named unity vs unitypackage?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on January 02, 2015, 11:43:57 PM
because its a scene, you can put it inside your project folder, and open the scene, I don't use any special assets, just capsule and cubes..
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on January 05, 2015, 12:33:16 AM
when the player trigger the death zone, the next state inside Death/Fall FSM will get the x position value from the Trigger Spawn FSM (I avoid as much as possible using global variable) and then set player position to that X value, with a fixed Y value, in this case 0.7, and 0 on the Z value. All the FSM are only on the player, the spawn point and death trigger does not have any FSM at all.

The problem I am having is that my level isn't intended to be like a flat floor. This doesn't work in this case because the player is dragged below the stage, making it fall continuously.

Is there a way I could add multiple points(empty objects) or add Get Position action with different local variables like a vector3 so my player can spawn at that point?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on January 05, 2015, 09:30:39 AM
in that case, get X and Y values from the trigger, but when applying the Y axis value to the player, offset it a bit, so the player doesn't stuck on the ground when spawning.

In scripting (or visual scripting in this case) use your imagination where is applicable, be creative when using actions and combining with another action, do this and you will get so far when creating games.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on January 05, 2015, 02:37:10 PM
in that case, get X and Y values from the trigger, but when applying the Y axis value to the player, offset it a bit, so the player doesn't stuck on the ground when spawning.

So you would say for the players FSM (like your example) that it will work if I add set position more than once on different spawns? That's a problem, because each spawn has a different X and Y value. This is a reason why I went with multiple death triggers in the first place.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on January 05, 2015, 04:58:46 PM
Yes it would work, but why don't you give it a try before asking here?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on January 05, 2015, 05:41:22 PM
Adding set position to the death FSM? Or add separate FSMs for each spawn trigger cube?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on January 05, 2015, 10:42:43 PM
Have you check the sample I've uploaded here? the trigger and the death trigger does not need any FSM at all, all of the FSM are being handled by the character.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on January 05, 2015, 11:25:00 PM
Spawn for each set position. Therefore, each set position action for each new FSM added to the player including a on trigger event. I am only asking this based on your scene example. So yes, currently the respawn and death trigger do not have FSMs on my end.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on May 08, 2015, 12:50:38 PM
Posted a new episode of the tutorial series, on how to create weapon system, cheers :)
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on May 08, 2015, 03:05:00 PM
Posted a new episode of the tutorial series, on how to create weapon system, cheers :)

So with that tutorial, you can set up FSMs to collect and switch from weapon to weapon?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on May 09, 2015, 01:01:45 AM
at this moment no, but you can modify it so it will be able to switch weapon.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on May 10, 2015, 03:04:56 AM
I guess it's something I will have to do some more research on.

(https://dl.dropboxusercontent.com/u/75323608/reset%20mini%20game%20.png)

I had this issue recently, with trying to have a object set up to create falling prefab objects that made the player respawn without turning the player into a prefab. Can that be done? Because it will only let me use prefabs.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on May 10, 2015, 08:22:13 AM
I'm sorry, but I didn't quite understand the question, could you explain it a bit more clearer?
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on May 10, 2015, 03:34:11 PM
I'm sorry, but I didn't quite understand the question, could you explain it a bit more clearer?

I have a game manager, it enables another FSM object, that FSM object creates wheels like in the image above. Here's the problem. When I made the wheel a prefab, I made a FSM for it to reset the players position, except I can't do that because it is restricted to only prefab GameObjects. And the player isn't set up to be one. So it's only a gameobject in a scene.

Like when whenever you want to do anything in playmaker, like specifying gameobject, I can only do that to prefabs because the wheel is one. Therefore, no objects in the scene objects window, like when you want to choose whether or not it's scene objects OR prefabs.

So heres my question. Is there a way to make a prefab object respawn/set a non-prefab gameobject's position? Like the player?

Hope that makes more sense to you.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on May 10, 2015, 07:33:32 PM
well in that case, in the prefab fsm you will need to create a gameObject variable, and then perhaps use "find game object by tag" action to find the game object with player tag in the scene, and then store the result to the variable before, and use that variable to reset its position.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: coffeeANDsoda on May 10, 2015, 11:29:51 PM
well in that case, in the prefab fsm you will need to create a gameObject variable, and then perhaps use "find game object by tag" action to find the game object with player tag in the scene, and then store the result to the variable before, and use that variable to reset its position.

Theirs find Find Game Object. Tried that, and not only it wont collide to the player with a player tag, I get a weird console message about UnityEngine.GUIskin.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on May 11, 2015, 12:05:57 PM
just uploaded the 8th episode, covering on how to create enemy. Cheers :)
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on May 16, 2015, 12:47:01 PM
New Episodes on the first post for the 2.5D Series, which is part 9 cover Deploying onto Android Device. cheers :)
Title: Re: 2D Physics Based Platformer Tutorial
Post by: djaydino on May 30, 2016, 11:39:33 AM
Hi,
just upping this back to 1st page. this is one off the better tutorials for beginners.
Title: Re: 2D Physics Based Platformer Tutorial
Post by: mirautaj on August 01, 2016, 05:49:25 AM
Hi,

I'm trying to do the 2D Sprite Based Platformer tutorial and everything else is working just fine, but the player has low gravity.

Here's a video to show you what's happening
Thanks
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on August 01, 2016, 10:21:10 AM
@mirautaj: I see on your project, the vector x and y is set to 0, try enabled the equal sign (use parameter option), and make it set to none, see if its working....
Title: Re: 2D Physics Based Platformer Tutorial
Post by: mirautaj on August 01, 2016, 12:22:09 PM
@mirautaj: I see on your project, the vector x and y is set to 0, try enabled the equal sign (use parameter option), and make it set to none, see if its working....

That worked. thanks!
Title: Re: 2D Physics Based Platformer Tutorial
Post by: cloud03 on August 01, 2016, 10:37:43 PM
You're welcome. Well basically the vector X and Y set to 0 it interferes with the Y speed, and it tries to set the value to 0 everyframe, that is why it is falling very slowly....