playMaker

Author Topic: 2D Physics Based Platformer Tutorial  (Read 82544 times)

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: 2D Physics Based Platformer Tutorial
« Reply #60 on: November 24, 2014, 09:26:55 AM »
Maybe that will do, put raycast after button jump pressed...

coffeeANDsoda

  • Hero Member
  • *****
  • Posts: 618
Re: 2D Physics Based Platformer Tutorial
« Reply #61 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.



« Last Edit: November 24, 2014, 08:37:57 PM by coffeeANDsoda »

coffeeANDsoda

  • Hero Member
  • *****
  • Posts: 618
Re: 2D Physics Based Platformer Tutorial
« Reply #62 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

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: 2D Physics Based Platformer Tutorial
« Reply #63 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)

coffeeANDsoda

  • Hero Member
  • *****
  • Posts: 618
Re: 2D Physics Based Platformer Tutorial
« Reply #64 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.

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: 2D Physics Based Platformer Tutorial
« Reply #65 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....

coffeeANDsoda

  • Hero Member
  • *****
  • Posts: 618
Re: 2D Physics Based Platformer Tutorial
« Reply #66 on: November 25, 2014, 04:24:17 AM »
Which for Get Axis? The global variable or local variable you made?

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: 2D Physics Based Platformer Tutorial
« Reply #67 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...

coffeeANDsoda

  • Hero Member
  • *****
  • Posts: 618
Re: 2D Physics Based Platformer Tutorial
« Reply #68 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.

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: 2D Physics Based Platformer Tutorial
« Reply #69 on: November 25, 2014, 05:05:23 AM »
You can try that, it should be working though...

coffeeANDsoda

  • Hero Member
  • *****
  • Posts: 618
Re: 2D Physics Based Platformer Tutorial
« Reply #70 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.
« Last Edit: November 25, 2014, 03:57:39 PM by coffeeANDsoda »

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: 2D Physics Based Platformer Tutorial
« Reply #71 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

coffeeANDsoda

  • Hero Member
  • *****
  • Posts: 618
Re: 2D Physics Based Platformer Tutorial
« Reply #72 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.
« Last Edit: November 25, 2014, 08:58:46 PM by coffeeANDsoda »

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: 2D Physics Based Platformer Tutorial
« Reply #73 on: November 25, 2014, 08:59:55 PM »
I'm using 4.3.4, so you will have to upgrade your Unity...

coffeeANDsoda

  • Hero Member
  • *****
  • Posts: 618
Re: 2D Physics Based Platformer Tutorial
« Reply #74 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?