make ball move only in certain direction.

PBEmpirePBEmpire Member Posts: 676
edited August 2012 in Working with GS (Mac)
i want my ball to move only at 45 or 135 degree angle if it hits slider. is this possible? when ball hits slider in my game, it moves most of the time straight.

Comments

  • HapiappsHapiapps Member Posts: 373
    Make an attribute called ball angle - integer

    When ball overlaps or collides with slider, change attribute ball angle to (in expression editor) random(1,2)

    In the ball,
    Rule
    when overlap or collide with slider, attribute ball angle = 1
    move behavior: set the direction to 45

    Rule
    when overlap or collide with slider, attribute ball angle = 2
    move behavior: set the direction to 135
  • PBEmpirePBEmpire Member Posts: 676
    thanks for ur help. let me try
    :D
  • PBEmpirePBEmpire Member Posts: 676
    no did not
    Make an attribute called ball angle - integer

    When ball overlaps or collides with slider, change attribute ball angle to (in expression editor) random(1,2)

    In the ball,
    Rule
    when overlap or collide with slider, attribute ball angle = 1
    move behavior: set the direction to 45

    Rule
    when overlap or collide with slider, attribute ball angle = 2
    move behavior: set the direction to 135
    no it did not work at all. can i send u the project file if u want to take a look? if not i will ask someone else to take a look.
  • HapiappsHapiapps Member Posts: 373
    Did you use the expression editor for the random? And no, I won't take a look.
  • PBEmpirePBEmpire Member Posts: 676
    ya i used expression editor. here is my attributes

    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. (I ALSO TRIED- CHANGE ATTRIBUTE TO (self.linear velocity.x)(self.maxspeed.))


    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))
  • PBEmpirePBEmpire Member Posts: 676
    i can only move at that direction if the ball is moving at that direction. i cant change direction if it hits edge.
Sign In or Register to comment.