Results 1 to 14 of 14

Thread: Need help with gravity settings.

  1. #1
    Knight
    Join Date
    Nov 2006
    Location
    Oregon
    Posts
    99

    Default Need help with gravity settings.

    Right now i'm just having him be able to run around and jump. You can use space while holding down a and d keys to get him to run, and up to jump. For some reason while treeworld works fine, when I set the gravity to 20 it's incredibly sluggish. Not sure why. It was created using the earlier versions of NS, so it might have something to do with some legacy junk.

    Maybe you can spot what's wrong. So I'm going to attach the zip. Thanks.

    Keith
    Attached Files Attached Files

  2. #2
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,340

    Default

    Hey Uhf,

    You need to add this somewhere after you add your brain:

    Code:
    	//limit movement to horizontal only
    	this:GetBrainManager():SendToBrainBase("control_filtery=0");
    Otherwise, this entity will be able to 'beat gravity' and attempt to hover. This is GOOD for top view games, very bad for side scrollers.

    Also, couple of general notes:

    The current build is a little shaky, some issues still need to be worked out

    Your .xml is using images located in your map dir?? Uh.. I've never done that before, that may cause problems. Images in .xml's should probably not be also used as tilepics.

    It's an interesting idea, and it may actually work, but I wanted to warn you I've never tested with doing it this way.

    Related to above, instead of using them as tilepic collisions, your entity should have a script line like: this:LoadCollisionInfo("~/player.col");
    Seth A. Robinson
    Robinson Technologies

  3. #3
    Knight
    Join Date
    Nov 2006
    Location
    Oregon
    Posts
    99

    Default

    Your .xml is using images located in your map dir?? Uh.. I've never done that before, that may cause problems. Images in .xml's should probably not be also used as tilepics.
    The tutorial was saying you could put images almost anywhere, and that, names that started with an underscore wouldn't be counted as holding a map...

    As far as images being used as tilepics, I'm not sure I understand where I'm doing that. Joe is an entity, so i'm confused?

    Related to above, instead of using them as tilepic collisions, your entity should have a script line like: this:LoadCollisionInfo("~/player.col");
    How am I using Joe as a tilepic collision? I did notice I wasn't explicitly loading the .col file (in fact I know that a col file hasn't even been created) So can you give me some more info on this, or point me in the right direction?

    Keith

  4. #4
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,340

    Default

    How am I using Joe as a tilepic collision? I did notice I wasn't explicitly loading the .col file (in fact I know that a col file hasn't even been created) So can you give me some more info on this, or point me in the right direction?
    With tilepics, after you add collision, an imagename.dat file is created/modified that contains all the collision data for it. Your entity started its life as a tilepic (if you check it's "data" in the editor, you can see the _TilePic info) and that is where it was getting its collision info.

    But, once your visual profile was loaded, you weren't using that tilepic visual anymore, but it's still retaining the collision from that. You could delete the _Tilepic etc data in the editor (in the entity properties dialog), and it will have no collision again.

    Yeah it's a little complicated for me too..
    Seth A. Robinson
    Robinson Technologies

  5. #5
    Knight
    Join Date
    Nov 2006
    Location
    Oregon
    Posts
    99

    Default

    Okay yeah, went back to the tutorial... Okay it says we don't need to use the tilepic collision (like you said), and now I understand it's because the collision is based on visual profiles and what not.

    Okay firstly how do I delete the tilepic collision data, secondly in my graphics folder I notice a HypnoIdle_right.dat -- is this the collision data it was using? How come there's no .dat's for the other files?

    Thanks

  6. #6
    Knight
    Join Date
    Nov 2006
    Location
    Oregon
    Posts
    99

    Default

    Okay checked it out, got a col file now... no problemo

    Okay i'm going to have to tweak this a bit, jumping is sluggish, not from there being anything wrong with the image, but just general tweaking. If I increase the force he jumps way too high... So how do I make the jumping snappier... like faster up (but not farther up), and faster down? Increase gravity?

    Keith

  7. #7
    Knight
    Join Date
    Nov 2006
    Location
    Oregon
    Posts
    99

    Default

    I've been playing around. To get it a bit more snappy, I had to up the gravity quite a bit, like I did it to about 100, and then increased the jump factor to compensate it's set at -4, I haven't tried it with add force constant yet. I will probably experiment a little tiny bit more, and then arrange the code a bit more neatly, before attempting eyeball aim.

    Quick question for anyone that reads this... mouse aim -- Does it usually flip the direction the character is facing? I know that halo zero does, and I think abuse might, but I want to know if i'm not supposed to be flipping face, with the keyboard or the mouse.

  8. #8
    Knight
    Join Date
    Nov 2006
    Location
    Oregon
    Posts
    99

    Default

    Okay just used addforceconstant instead of just addforce -- here's the funny thing about that basically i couldn't jump very high... because the gravity was so high (at 100)... so i cranked addforce up to -400 -- now it seems to move as snappy as I would like, but it still goes too high... still playing around.

    I've also tried to add this::StopY() -- which doesn't jump very high at all then. So i'm wondering, how to properly use it? How do I detect how high he's jumped. To stop him?

    There's alot of stuff to learn about this thing

  9. #9
    Knight
    Join Date
    Nov 2006
    Location
    Oregon
    Posts
    99

    Default

    I'm also wondering if you can or will in the future have the ability to have a new collision poly for each frame of an animation?

    If not that's cool, but thought I would ask.

  10. #10
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,340

    Default

    Box2D is a real physics system, so when modeling a character's jump you have to think in terms of 'applying force' and at what stage in the jump you want to apply it.

    If you haven't worked with this kind of system before it can take some getting used to... but the payoff is lifts, collisions, etc will look and feel great.
    Some ideas:

    Look up Entity:SetGravityOverride() if you want the player to temporarily have a different gravity during a jump - this way you don't have to change the Map gravity.


    AddForceConstant() is for applying things over time, for instance, internally, AddForceConstant(map gravity) is how gravity is added is added to each thing internally.

    I'm also wondering if you can or will in the future have the ability to have a new collision poly for each frame of an animation?
    Well, you can change the collision object at any time but it's not tied to the animation system, so "every frame".. hrm. In general this is a bad idea anyway, as you could put the creature/player in an impossible location and he'd stuck or maybe fly through a wall.

    But maybe it would make since for say, a left-right collision version.. do you know any games that do it that?
    Seth A. Robinson
    Robinson Technologies

  11. #11
    Knight
    Join Date
    Nov 2006
    Location
    Oregon
    Posts
    99

    Default

    That didn't exactly tell me how to determine a jump height. I guess I could just determine a number of calls to update and tell ti to "stopy' then... When you add a force, it's not going that high, it's adding it on to the current height... That's cumulative, unless I misunderstood what you're using.

    Can I be sure that update is called x amount of times per second (or whatever timing method it uses, is constant?)

    Keith

  12. #12
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,340

    Default

    That didn't exactly tell me how to determine a jump height. I guess I could just determine a number of calls to update and tell ti to "stopy' then... When you add a force, it's not going that high, it's adding it on to the current height... That's cumulative, unless I misunderstood what you're using.
    AddForce doesn't add to the height directly, it causes your entities force to change so it moves faster/slower, which modifies your height.

    You could calculate your height by saving the Y pos before you jump and checking it later, but StopY() to freeze in the middle of a jump would look/feel awfully weird.

    Can I be sure that update is called x amount of times per second (or whatever timing method it uses, is constant?)
    If you multiplay your addforce by the "step" value, it will always be consistent across computers. The Update(step) function actually gets called between 60 (guaranteed minimum) and 120 times a second to match the current refresh rate for smoother gameplay.

    But forget all that, and do something like this maybe:

    Code:
    //do the jump in three bursts, over the first 0.2 second
    
    Schedule(0, this:GetID(), "this:AddForce(m_vJumpForce)");
    Schedule(100, this:GetID(), "this:AddForce(m_vJumpForce)");
    Schedule(200, this:GetID(), "this:AddForce(m_vJumpForce)");
    Using schedule is easy because it makes sure that things happen at the right time.
    Seth A. Robinson
    Robinson Technologies

  13. #13
    Knight
    Join Date
    Nov 2006
    Location
    Oregon
    Posts
    99

    Default

    I still can't figure out this jump stuff.

    Essentially I want him to jump really fast, come down really fast, but only jump up a certain amount. You can't just check on the y position, because if he jumps onto a platform the y position will be different.

    Right now he only calls AddForceConstant when he's "OnGround" essentially. If I call it, I'm assuming that it adds the -400 force just once, instead of multiple times. So how do I change it so that when it gets to a certain height, the -400 force is not there?

    If that makes any sense?

  14. #14
    Knight
    Join Date
    Nov 2006
    Location
    Oregon
    Posts
    99

    Cool

    I went ahead and reassessed the game and settings. I came to the conclusion that dropping it down to -250 instead of -400 -- which means it doesn't go as high, is acceptable. So I'm going to attach it, and ask you guys if you seems responsive enough. Keep in mind I haven't really fixed the "hopping" yet (by holding down the button he hops, i'll fix that in a bit).

    A, D for left/right -- W to jump, space to run, although running really isn't relevant here.

    Give it a try and let me know.

    Keith
    Attached Files Attached Files

Similar Threads

  1. What are your preferred FQ settings?
    By FearTheWhammy in forum Funeral Quest
    Replies: 0
    Last Post: 04-09-2008, 12:57 PM
  2. preserving default app settings...
    By harrio in forum Novashell Game Creation System
    Replies: 5
    Last Post: 04-04-2008, 02:30 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •