The Daily Click ::. Forums ::. Klik Coding Help ::. I need an easy way to switch between different physics
 

Post Reply  Post Oekaki 
 

Posted By Message

JetpackLover



Registered
  01/03/2007
Points
  212
20th May, 2009 at 22:50:26 -

What I mean by Physics is stuff like Max X velocity and Max Y velocity. The reason I need to change them is for things like in air combat, that way when in the air the Max Y velocity is a low number so it slows the decent of my character. The problem I'm having is being able to switch between the different Max X and Max Y velocity. The way I am doing it now seems much more complicated then it needs to be. As an example this is how I do it

I'm using the Platform Movement object btw

//this is for the main physics
(group)Normal Physics
Always > Deactivate (group)Sword air control + Set Max X velocity 500 + set Max Y velocity 900

//this is so there is always a switch on that allows the (group)Sword air control to turn on.
(group)On/Off Air control
Jumpslash1 is playing > Activate (group)Sword air control

//this is what sets up the new physics
(group)Sword air control
//This is so the player is delayed in the air and can't move to far horizontally
Jumpslash1 is playing > Deactivate (group)Normal physics + set Max X velocity to 200 + set Max Y velocity to 300

//this is for turning off the (group)sword air control

(group)Sword air control
Jumpslash1 is not playing > Activate group(Normal Physics) + Deactivate (group)Sword air control


And this is basically how I've handled this in a nutshell. And this is just for one physics change, I'm hoping to be able to make multiple changes. I'm posting here because I'm hoping there is a more efficient way of doing this. I did my best to pseudo code this out so if it needs to be explained better just let me know and I'll do my best.

 
http://www.invincibletime.com/

Devlog for HD MMF Game Omulus. Check it out because it's gonna be awesome. http://omulus.tumblr.com/

Follow me on the twitters https://twitter.com/JetpackLover


Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
20th May, 2009 at 23:06:23 -

couldnt you just have one physics engine and change the values?

the best way would to just to mimick real physics. speed, time, velocity, terminal velocity, angle, gravity and then just change the values during moments of special physics. in air combat you would simply lower gravity and the character would be floaty and fall slower.

it does seem rather overtly complicated to have multiple groups for multiple instances of varying physics.

 
n/a

JetpackLover



Registered
  01/03/2007
Points
  212
20th May, 2009 at 23:31:01 -

I originally tried manipulating gravity but it was too hard to control. If the gravity was at like 1 or something and you ended up moving upward then my guy would go flying off the screen. It works well for falling and stuff, though to be honest I tried this out awhile ago and since then I've learn a lot more I believe. So perhaps I should try it that way again.

Anyway I don't have a problem with just changing values my problem is changing them back so you aren't all floaty and stuff while normally running around. Perhaps I'm not fully understanding how this is supposed to be done.

Also I'm using groups because of the way I change the physics back which is by saying "jumpslash1 is not playing" and I figured if I didn't have groups it would make it difficult to have multiple physics because they would be contradicting other lines of code.

I'm totally willing to trash all of this code if/when someone knows of a better, less code, more efficient way of doing this.

A great example of what I'm trying to do is in Noitu Love 2: Devolution

When Xoda attacks in the air(with or without enemies) her Max Y or Gravity is lowered(not sure) and that allows her to gently descends down when she attacks in the air which allows her more time in the air.

There are also examples of this featured in Devil May Cry games which is basically what I'm trying to achieve with this game.

 
http://www.invincibletime.com/

Devlog for HD MMF Game Omulus. Check it out because it's gonna be awesome. http://omulus.tumblr.com/

Follow me on the twitters https://twitter.com/JetpackLover


Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
21st May, 2009 at 00:09:19 -

well thats easy.

if youre using a value to make the character fall. so like yvel is at 10, meaning youre falling, when you start attacking set it to 0 so you stop falling, and then it will start increasing again if you arent attacking.

say youre doing it like this.

player is at 10y and the ground is at 100y. youre 90 pixels above the ground. to make it fall you add a value that increases as youre falling. so at the peak its falling slowly and gains speed. you fall 1 pixel, then you fall 2 more then 4 tjem 8 until it hits terminal velocity (it cant fall any faster). when you attack in the air you change that value back to 0 (or 1 so you can keep falling but rather slowly).

i hope that makes sense? i did this kind of thing in a game i was working on but lost in a hdd crash. so im not EXACTLY sure how i was doing it but it was something like that.

 
n/a

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
21st May, 2009 at 15:50:40 -

I wrote a physics article full of bugs:
http://www.create-games.com/article.asp?id=1594

But it should explain what Cecil's trying to say in a clearer way

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image
   

Post Reply



 



Advertisement

Worth A Click