Actor/Particles help - Laser Beam - how to control size with power bar

2»

Comments

  • dandandan18dandandan18 Member Posts: 35
    edited September 2013
    @RThurman thanks again, appreciate your help and patience so much!

    How do I store the difference between the two actors in an attribute? Do I use a save and load attribute behaviour?
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    edited September 2013
    To find the difference you just use a change attribute behavior. For example;

    Change attribute: self.theDifference To: otherActor.Position.Y-self.Position.Y

    If on the other hand, you want to quit the game and have it store the value of an attribute so that its saved for the next time the game is opened, then you would use save and load attribute.
  • dandandan18dandandan18 Member Posts: 35
    @RThurman I've been busy over the past few days so haven't had time to check this thread but thanks a lot i'll give that a shot. Btw, I have quite a few real attributes, what happens if I change the values?
  • dandandan18dandandan18 Member Posts: 35
    edited September 2013
    @RThurman Here's what I did...

    1. Made self (real) attribute in laser beam called 'difference'

    2. In enemy actor - Change attribute 'Game.Enemy Y' to 'Self Position Y' - changed it the otherway round to see if it made a difference but it didn't...

    3. In Laser beam - Constrain 'Laser.Y' to 'Enemy Y + Self.Difference'

    this is basically - Constrain 'Laser.Y' to '(Enemy Y + (Enemy.Y-Laser.Y))'

    Don't understand how this would make the laser position Y move down at the same speed as the enemy Y

    4. Made my enemy destroy after 2 seconds of collision...


    Not sure where It's gone wrong
    - is it supposed to be a game actor not a self actor?
    - something with the enemy actor and the attribute.


    When I preview it when the laser beam collides with an enemy actor it moves up high - due to no 3.??


    I really appreciate your patience :) hopefully this will be my last question.


    Could another possible way of doing this be to match the accelerate (at 270degrees) of the Laser Beam the same as the Enemy actor when it collides?

    The 3 enemy actors are set at speed 70 but one of them is a tiny bit slower when they are lined up - the physics numbers are all the same..
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    It looks like #2 should be using 'self.difference' instead of 'game.EnemyY'.

    The logic could look like:

    When overlaps or collides with actor of type enemy
    --Change Attribute: self.difference To: game.EnemyY - self.Position.Y
    --Constrain Attribute: self.Position.Y To: game.EnemyY - self.difference
    --Timer (after 2 seconds)
    ----Destroy this actor
    Otherwise
    --Move laser up the screen
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    You also asked if there is another way to do this (by matching acceleration). The answer is yes, there are potentially many ways make the laser beam appear as if it is being pushed down by the enemy actor. Among other things you could:

    1) match accelerations (as you mentioned)

    2) use a collide behavior and just have the laser bounce downward when it touches the enemy

    3) have an actor cover the back side of the enemy (but layered above the laser beam) so that you cant see the laser poking up past the enemy. It would appear as if the laser was shortening.

    4) use the replicate the behavior and just have 'beam segments' moving up and down the scene.

    5) constrain the height of the laser beam (instead of the y-position)

    6) use an animate behavior to mimic the laser effect

    GameSalad is pretty versatile like that. Use what works for you!
  • dandandan18dandandan18 Member Posts: 35
    edited September 2013
    for no 3. will this work... -

    Constrain Laser.Y to Enemy.Y
    It looks like #2 should be using 'self.difference' instead of 'game.EnemyY'.

    The logic could look like:

    When overlaps or collides with actor of type enemy
    --Change Attribute: self.difference To: game.EnemyY - self.Position.Y
    --Constrain Attribute: self.Position.Y To: game.EnemyY - self.difference
    --Timer (after 2 seconds)
    ----Destroy this actor
    Otherwise
    --Move laser up the screen
    @RThurman great! Yes, on the Constrain attribute I put Game.Enemy Y + Self Difference instead of a - (minus)

    on the Otherwise how would I move the laser back up the screen to match the power of the slider - the move behaviour only has a speed acceleration option..

    At the moment it's very buggy without the laser moving back up.

    Was thinking of putting this in the otherwise section -

    Constrain Attribute 'Game.Power' to (blue Slider Actor) 'Self Position Y - Self Slider min'
    but It's not the laser actor so I'd have to make more attributes and link them up like this?
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    edited September 2013
    'Game.Power' is already being set in the slider actor. So you don't need to mess with it (in the laser beam actor).

    The otherwise section (of the laser beam actor) would just need the constrain that you said you already have working:
    Constrain self.Position.Y To: (6*game.Power-( self.Size.Height/2))
  • dandandan18dandandan18 Member Posts: 35
    @RThurman thanks a lot, it's a bit buggy like sometimes after you destroy the actor the laser doesn't appear
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    @dandandan18 -- sorry, its not clear what actor you are referring to. Do you mean that after the laser actor is destroyed, it does not re-appear? If yes, then you would need to spawn another laser actor (since the last one was destroyed).
  • dandandan18dandandan18 Member Posts: 35
    @RThurman the actor gets destroyed by the laser - so I've not destroy actors in the laser. but in the actors that you kill. When theres a few bugs after each other with a few seconds apart the laser disappears and doesn't work. Really appreciate your time and patience
Sign In or Register to comment.