I am having problems getting a ball to move at a constant speed

PBEmpirePBEmpire Member Posts: 676
edited August 2012 in Working with GS (Mac)
my ball is not moving at constant speed. when it collides with the slider, it slows down speed. i have everything set to 0 except for restitution-1. i have set- when ball collides with slider, change attribute( self. motion.linear.velocity.x) to (self. motion.linear.velocity.x)(max.speed).

i have also tried- change attribute( self. motion.linear.velocity.x) to (max.speed).

or does it have to do with ball velocity? - random(0,360) is what i am using so as to get perfect bounce.

Comments

  • PBEmpirePBEmpire Member Posts: 676
    guys i URGENTLY NEED HELP!! as my app was almost done!!! except for polishing. :((
  • PBEmpirePBEmpire Member Posts: 676
    edited August 2012
    -comment removed-
  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    Dude, chill a bit. Complaining like that is definitely going to get you a quick answer, isn't it?


    You could put a time:
    Every 0.1 second,
    Change attribute self.motion.linear.velocity.x to whatever


    Try that.
  • PBEmpirePBEmpire Member Posts: 676
    ok sorry for my temper. i will remove it. :D

    i tried but it did not work. instead made my game lag. but i seem to get result when i put change attribute (velocity x) to (velocity x )( max.speed) but occasionally ball goes super slow till it dies.maybe due to shape of slider
  • ORBZORBZ Member Posts: 1,304
    What is the restitution on the slider and the ball? Each should be set to 1 and make sure there is no drag on the ball. Also, make sure the slider is not movable (uncheck movable) or else the slider will be moving slightly backwards with each collision absorbing some of the force of the impact.
  • SlickZeroSlickZero Houston, TexasMember, Sous Chef Posts: 2,870
    If the ball doesn't need to change speeds, and you want it to travel at a constant one, use constrain attribute for the velocity.
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Dude we are not your servants! A headline like that will get you ignored every time.
  • ORBZORBZ Member Posts: 1,304
    edited August 2012
    @SlickZero - how do you suggest constraining the velocity to a fixed value if the ball could be moving in both x and y directions at the same time?

    Also, ya @gsrockz123, totally crap subject line. Try adding please next time.
  • PBEmpirePBEmpire Member Posts: 676
    edited August 2012
    i know my title was crap. btw my restitution is 1. i a have a actor to stop the slider from sinking. i have 0 for everything except restitution. constrain attribute did not work. ball only moves in 1 diretion...
  • PBEmpirePBEmpire Member Posts: 676
    someone must an answer!!! i constrained attribute but it did not work
  • PBEmpirePBEmpire Member Posts: 676
    sry u dot get it. u know the brick breaker template in the arcade right? i m using that but i have made mouse position to touch. now the ball whenever it hits the slider slows down speed and sometimes just stops. i would also like to know if follow mouse position x works in iphone.
  • PBEmpirePBEmpire Member Posts: 676
    If someone is free, can u help me test the game? i have saved 1 scene of the game for testing.
    Email- gamesaladapps@gmail.com
  • PBEmpirePBEmpire Member Posts: 676
    i have serious problems with constraining speed as i cant simply constrain velocity x to speed as i have functions assigned to it.
  • PBEmpirePBEmpire Member Posts: 676
    my blood pressure is growing high :(( i dont know why people dont have this answer. i have my attribute set- change attribute ball.motion.velocity x to ball.motion.velocity x+2*(self.position x - game.mouse.position x) . this gives the ball the perfect bounce off bricks and walls but reduces speed. if i put constrain velocity x to 350(my speed), then the perfect bounce will totally disappear .
  • PBEmpirePBEmpire Member Posts: 676
    edited August 2012
    Try this out and see if it's what you want.
    i am using that template but i change 2 things.

    1) i changed paddle rule from mouse position to touch position.

    2) i change ball bounciness from 2 to 1.

    i am making an iphone game so i changed mouse position to touch position. to get perfect ball bounce off walls, i changed bounciness from 2 to 1. So now i have narrowed down the problem to these 2 and i am sure its with these as i have not changed anything else from template except i added many many other bricks and lose,win scenes

    EDIT: I found that changing bounce to 1 in the template reduces speed by a margin but not as bad as my game. setting it back to 2 in the template does not reduce speed but the bounce off walls is bad.
  • PBEmpirePBEmpire Member Posts: 676
    edited August 2012
    hope that clarifies things
    using gs physics engine collide does not work at all btw :(
  • PBEmpirePBEmpire Member Posts: 676
    I think u can close this as i found an answer at last!!

    for future purpose, my solution- i changed density of paddle form 0 to 1000 and it worked like a charm!!! :))
Sign In or Register to comment.