Bullet behavior and Physics behavior

This forum is currently in read-only mode.
From the Asset Store
This pack contains 10 types of bullet effects, with different shapes and colors.
  • I'm making a Space War type game and having a little problem with Bullet Physics.

    I want the bullets in the game to have force applied towards a center Black Hole object... I have a player ship with this behavior working perfectly using Physics Behavior (thanks Davioware!). But when I made a bullet and added both Bullet and Physics behavior to it in an attempt to do the same thing, everything went terribly wrong.

    So, I'm assuming that Bullet Behavior and Physics Behavior don't play nice together? If that is the case, what is the most efficient way to manually create bullet movement? Is there an example/faq/tutorial for this that anyone can point me at?

    Thanks!

  • Why do you want your bullets to use physics behavior specifically? Will they need to collide and bounce around physically? If not then physics behavior shouldn't be used. The only time you should use it is if you want physics based interaction between objects. Using it solely for the purpose of vector based movement/inertia is inefficient; for that you should use custom movement behavior. In general you shouldn't combine two movement behaviors unless you're manually toggling between them for a certain reason. Physics behavior hijacks the x,y, and angle of an object, so adding a bullet behavior on top will just apply angle based movement to the object after its movement has already been physically solved and applied by physics behavior. Bullet behavior is dead simple, and is equivalent to the "move at angle" action, minus the time-delta adjustment.

  • It's not that hard to do physics based bullets. Do you want something like this?

    http://dl.dropbox.com/u/10316081/phymachgun.cap

  • Why do you want your bullets to use physics behavior specifically? Will they need to collide and bounce around physically? If not then physics behavior shouldn't be used. The only time you should use it is if you want physics based interaction between objects. Using it solely for the purpose of vector based movement/inertia is inefficient; for that you should use custom movement behavior. In general you shouldn't combine two movement behaviors unless you're manually toggling between them for a certain reason. Physics behavior hijacks the x,y, and angle of an object, so adding a bullet behavior on top will just apply angle based movement to the object after its movement has already been physically solved and applied by physics behavior. Bullet behavior is dead simple, and is equivalent to the "move at angle" action, minus the time-delta adjustment.

    The Physics behavior is how I modeled the Black Hole. By using the "Add Force Towards" action.

    I was just trying to achieve the same effect with the bullets... If you shoot them past the black hole, they CURVE towards it, and/or get sucked in entirely. That way, during the game, you can do "Trick shots" where you aim near the Black Hole and the shot will angle around it and make a complete left turn (or whatever.)

    So, is there a manual way to do "add force towards" using Bullet or Custom movement Behaviors?

    I'll attach the file I'm working on (minus bullets) so you can see the "add force towards" effects.

    http://www.mediafire.com/file/jjr27flssssxluo/How%20to%20Add%20Bullet.cap

  • It's not that hard to do physics based bullets. Do you want something like this?

    http://dl.dropbox.com/u/10316081/phymachgun.cap

    Got it. I'll try it this way. Thanks!

  • use custom movement and "set speed toward position", and choose accelerate as the type. It functions the exact same way as physics. Like I said, if you want vector based movement (ie. Inertia physics, without the collisions) then use custom movement.

  • use custom movement and "set speed toward position", and choose accelerate as the type. It functions the exact same way as physics. Like I said, if you want vector based movement (ie. Inertia physics, without the collisions) then use custom movement.

    Got it... I now have it working with both Physics and Custom movement. They're more or less identical (still playing with the math.)

    Is custom movement more efficient in terms of processor overhead? Is that what makes it a better choice than Physics? Just curious.

    Thanks again!

  • One last question (I hope ): Now that I'm no longer using the bullet behavior, what is the best way to set a range for the bullets? My guess would be some version of destroying it over TimeDelta? Also, should I be using TimeDelta to regulate the bullet speed (so it will run the same on different computers)?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Is custom movement more efficient in terms of processor overhead? Is that what makes it a better choice than Physics? Just curious.

    Yes.

    One last question (I hope ): Now that I'm no longer using the bullet behavior, what is the best way to set a range for the bullets? My guess would be some version of destroying it over TimeDelta? Also, should I be using TimeDelta to regulate the bullet speed (so it will run the same on different computers)?

    Using timedelta in your movement calculations makes the game run at the same relative speed regardless of the frame rate. For example, when the frame rate drops due to lag, objects will perform large steps of movement, which may result in missed collision or other unwanted things. You can also set a special setting for timedelta which remedies the aforementioned problem; it modifies the timedelta if the value gets to low, so that the game goes from "skip frame" lag, to "slowdown lag" if passes a certain threshold. Timedelta is not mandatory however. You can use a fixed frame rate for when you want to program to run with frame based logic, instead of time based logic. Without timedelta however, if you select V-synced framerate, then your game will run at different speeds depending on the monitor's refresh rate. If you need pixel perfect collisions, reliability and consistancy (ie. low res platformer), then use a fixed frame rate. If you want to be able to slowdown time in your game, then you need to incorporate timedelta (there are ways around that but I won't get into that).

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)