ball physics

prajpraj Member Posts: 68
edited July 2012 in Working with GS (PC)
since no one answered my previous post let me repost it.

i have problem with ball physics. the ball does not bounce off wall properly.

here is my rules-

Random initial velocity- speed 300. (250,290)

When collide with paddle, change attribute- self.motion.linear velocity x to self.motion.linear velocity x +1*(self.position x-game.mouse.position x) ------ this is iphone game so i made buttons to move left or right.

When attribute-self.motion.linear velocity y > -15
self.motion.linear velocity y <-15
then, change attribute self.motion.linear velocity.y to random(70,120)*(1)^(random(1,2))



Ball density-100
paddle density-1000
wall density-10000

PS. i have changed the values and densities but the problem is there or sometimes worse.

My problem is that the ball does not bounce off wall properly. many times when it hits a brick and bounces off and hits the wall, after 2 bounce or so it changes direction and goes back up without hitting the paddle. This problem is also there in the template in arcade. Can someone help me?

Comments

  • prajpraj Member Posts: 68
    anyone? :(( :((
  • QuestionManQuestionMan Member Posts: 81
    I've been fooling around myself. I just made a square wall where I have 5 or 6 balls inside and they all bounce around just fine. BUT I did have similar problems as yours, had to troubleshoot them out.

    Some of the things I did:

    All 4 of the walls are the same actor. Set the wall actor to NOT movable, set the density and stuff to 0, set the restitution (aka Bounciness) to 1, and moved them just outside the visible range. I also had the 'react as' function set to rectangle.

    The balls are also the same actor. I actually am just using a square picture so I can see the rotations are working. Anyway, I set them to act as 'balls'.

    My biggest change, not sure if this applies to you, is that I had a 'touch' actor that comprised the entire screen. I made it so that when I touched anywhere, the balls would begin moving. I had to make this touch screen essentially nonexistent so that it didnt interact with the balls. Before I realized this, I had some VERY odd behaviour, but was funny when I realized what was causing it.

    Oh and I saw in tshirtbooths video that he mentioned that the density, restitution and the other value are supposed to be between 0 and 1, as in a decimal percentage. So that may also be causing your problems.


    I think I may have to charge up my credit card and get me a Mac though, the lack of tutorial vids for Windows is killing it. But I spent a good 8 hours today tinkering and had a lot of fun by now so I think I'm hooked. Good luck dude.
  • QuestionManQuestionMan Member Posts: 81
    Oh and stupid me, I had to change the 'collides with' function to only interact with the appropriate actors. ie. it was colliding with my touch actor that was invisible and filled the whole screen lol
  • PBEmpirePBEmpire Member Posts: 676
    edited August 2012
    lol
Sign In or Register to comment.