Space style movement

This forum is currently in read-only mode.
From the Asset Store
Spaces Ambience contains 102 Sounds: 53 track and 49 sounds
  • Hey everyone, I think this is the right place to post this.

    For a while now I've been trying to make a movement engine type thing that's similar to Infantry/Cosmic Rift/Subspace WITHOUT using the physics engine.

    Now I'm all ears to hears reasons why I should use it, I just wanted to see if it could be done realistically without the physics engine since (to my understanding) object manipulation and collisions would be easier without it no?

    For those unfamiliar with the type of movement i'm going for, it's like a realistic space type movement, basically, you fly in one direction for a while, and since there's no 'friction' on you, if you let go of forward, you will just keep on floating away in the direction you're travelling in, regardless of which way you're facing.

    But what i'm finding HARDEST to achieve is realistic bounces from collisions, bouncing off at the right speed and angle is so hard for me to get going, i've recently been trying with the ball object but i'm having a lot of trouble getting it to look in a different direction to the way it's going. My current method uses no behaviours and moves the object quite realistically, but to get the realistic bounces i have a huge loop that shoots out a whole bunch of detectors that 'feel' the shape of the area around the player and then when the player collides with anything, it knows which direction to bounce off in. But it's a very long winded way of doing it and it doesn't quite work well with small enclosed areas.

    If anyone could help me out here that would be awesome!!

    I'm totally ok with scrapping my current idea if you got something better. Or better yet, convince me to use the physics engine

  • I suppose you're talking about the movement like in Asteroids, right?

    i'm having a lot of trouble getting it to look in a different direction to the way it's going.

    A simple solution is to use two sprites: one with the movement being invisible, and the other showing the spaceship. You can always set the spaceship graphic to the position of the invisible marker, and then rotate the graphic to any angle you want.

    [quote:1gc3edjy]But what i'm finding HARDEST to achieve is realistic bounces from collisions

    If you're using the ball movement, the 'Bounce off object' action can take care of all that for you.

  • Yeah that's what I've also tried doing, but as usual there's catches.

    In any case, I quickly tried doing what I want using the physics engine instead and it actually works quite well, except I don't seem to be able to set a maximum speed. I can get the X and Y components for the velocity, but is there some equation using those two that return the actual velocity/speed of the player? Hmmmmm wait would that be pythagora's? That square root bug is fixed right?

    Interesting......

    Anyway the reason I haven't went with the ball movement + another sprite idea is, while the bouncing was great, it was hard (while i acknowledge not impossible) for me to set up a thrust type situation. So if i'm holding forward and facing a wall, i hit it, bounce off, slow down to a stop and then start accelerating towards the wall again. Granted I only gave myself about 5 minutes coding time so I'm sure it's quite possible, but I find the physics one is more accurate. I just hope it doesn't mess up any collision codes i put in later.

    Anyway as I realise this thread may now be redundant, thanks for reading anyway

  • I tried out the pythagoras thing for the speed, and most of the time, the value I get returned is -1.#IND which I believe was a problem previously, I thought it had been fixed I'm using the most recent version of construct

  • Sorry for all the posts, I realised I was doing the wrong equation cause I was sure that bug was fixed, the wrong equation I was using was Speed = sqrt((sqrt(Xvel) + sqrt(Yvel)))

    I know i know it's waaaay off, I fixed it up and it works now but but numbers wise, shouldn't it still not return that -1.#IND shouldn't it? well whatever, hopefully I won't have to post in here again

  • The square root bug was fixed, you'll get -1.#IND if you try to take the square root of a negative number, which is not mathematically possible. Remember the formula is:

    sqrt(x*x + y*y)

    If that still gives -1.#IND, try deleting the sqrt and see if the middle expression is negative.

  • The pythagoras thing is working fine now that I got the right code in. So now I can get some idea of the speed in any given direction. So I know he's travelling around 10 .... 10 what? oranges?

    Also I want to be able to use time delta with this physics movement and it tends to put a bit of a spanner in the works... making everything move REAL slow.

    Now I realise in a space situation there is no maximum speed, but this is a game and I want to be able to set a maximum velocity on this sucker, so far i'm finding it hard to do. Also since i haven't coded in any deceleration, i've been using the damping, but increasing that makes me have to apply a whole lot more force to move the dam thing. Should i just set the velocities instead of applying force? I'm not very physics minded.

    Thanks for the help so far, if this is at all annoying just ignore it lol

  • So I know he's travelling around 10 .... 10 what? oranges?

    If you're using a built-in or timedelta-based movement, it's 10 pixels per second. I'm not sure the units of the physics engine.

    [quote:309y660d]Also I want to be able to use time delta with this physics movement

    Not necessary - the physics movement is already timedelta based.

    [quote:309y660d]I want to be able to set a maximum velocity on this sucker, so far i'm finding it hard to do

    In the event where you increase the speed, add a condition that checks if the speed is less than the maximum speed. Typically you'll have something like this:

    + Up arrow is pressed

    -> Add 1 to speed

    If you make it like this

    + Up arrow is pressed

    + Speed < 100

    -> Add 1 to speed

    then you can never exceed a speed of 100.

  • Physics is timedelta already? But I can't seem to slow it down with timescaling

    I find timedelta very useful, but since physics uses different measurements, i'm finding it hard to 'quantify' in my head.

    In any case, that speed check thing is what I've usually been doing, but what mostly happens is, once I reach the maximum speed, I can no longer change direction (I use the mouse pointer for direction) and it just keeps flying off in the direction i was going once i reached max speed. As soon as I am no longer going max speed i can change direction fine. This could just be sloppy coding on my part I dunno. I've always found setting a max speed on a physics based engine thing rather difficult...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Physics is timedelta already? But I can't seem to slow it down with timescaling

    That's been fixed in the next build.

    I think you should post a .cap so everyone can see whats going on.

  • Nevermind, it was my code being sloppy, I fixed it up as well as having a couple of breakthroughs

    I now have exactly what I wanted

    Thanks for your help and input, also can't wait for the time scaled physics

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