how can i measure the velocity on actor?

chicopchicop Member Posts: 263
edited November -1 in Working with GS (Mac)
Howdy

I am trying to figure out how i can get the following to work:

I want my A actor to destroy my B actor.. however i want this to be done at a convincing velocity.. so if actor A hits actor B at to low a velocity actor B will not break.. but if actor A hits actor B at a high velocity actor B will break... then breaking 10 B actors will unlock the next level...

so how can i measure the velocity on actor A and then have that measurement tell actor B to either be destroyed or not?

any help is really appreciated

Thanks

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    create a real game attribute game.velocity

    In Actor A
    Rule - when Actor A collides with Actor B
    change attribute game.velocity to sqrt((self.motion.linear.velocity.X^2)+(self.motion.linear.velocity.Y^2))

    In Actor B
    Rule - When collides with actor A
    ------Rule When game.velocity is > ????
    --------Destroy Actor
  • chicopchicop Member Posts: 263
    thanks for your reply!

    in the part sqrt which parts sets the velocity? is it ^2 and is this adjustable? and does this measure the velocity the actor has before it impacts with the other actor?

    i ask because when i run this A hits B but B bounces up and hangs in mid air.. how ever if i change the > to < it will break actor B

    thanks
  • ORBZORBZ Member Posts: 1,304
    Velocity = magnitude(linearVelX,linearVelY)
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    ORBZ said:
    Velocity = magnitude(linearVelX,linearVelY)

    Really? Cool!
  • chicopchicop Member Posts: 263
    thanks

    i still get the same result though.. ( actor B bounces and floats around...where it should destroy and play destroy animation) so i am really not sure at which velocity the ball is traveling whether i say is greater then 1 or 500 the actor wont break.. only when i do a is less then...

    Orbz, is that velocity= magnitude.. do i put that in actor A or B?
  • ORBZORBZ Member Posts: 1,304
    an object's total linear velocity, regardless of direction is the magnitude part of it's vector. where a vector is a combination of direction and magnitude. we ignore the direction with the magnitude function such that:

    totalVelocity = magnitude(linX, linY)

    it's direction of travel can be calculated as such:

    direction = vectorToAngle(linX, linY)
  • chicopchicop Member Posts: 263
    this still boggles me...

    at which point does it know actor A is moving to slow so it will not destroy actor B?
  • HymloeHymloe Member Posts: 1,653
    Thank you ORBZ, that is awesome! Just what I was after. :)
  • shusain93shusain93 Member Posts: 6
    I still can't get this working. What I'm doing is I have to cars and I want the one moving faster to destroy the one moving slower. I tried this and it doesn't seem to work...
  • wormilwormil Member Posts: 127
    Making you a demo, one sec.
  • wormilwormil Member Posts: 127
    Yeah, sorry for that, was on the phone to the US with my mum. Where do you want a demo sent?
  • chicopchicop Member Posts: 263
    i had put this to rest but a demo? id be in to that if your willing to share it?
  • wormilwormil Member Posts: 127
    I keep forgetting I'm not in America any more and people will respond when I write them notes!

    I'll publish the demo in a bit, after I get some feedback on how to publish just a demo and not an official game.
  • wormilwormil Member Posts: 127
    Without further delay, feel free to check out what I've done. It was just a quick hack, but it does work.

    You can find it under 'velocity demo'. Hope this helps some.
  • chicopchicop Member Posts: 263
    dude this is most awesome!

    thanks a million!
  • wormilwormil Member Posts: 127
    Yeah, no worries :) Sorry it took so long to upload, I get a bit swamped with real life D:
  • shusain93shusain93 Member Posts: 6
    Is there any way you could send me the project. This is STILL stumping me :(
  • wormilwormil Member Posts: 127
    If you go to the game salad screen where the demo templates are, i've posted it as "Velocity Demo".

    If for some reason you can't get that, I'll post the file online.
Sign In or Register to comment.