How to calculate the velocity of an actor?

So i got an actor that collide diagonally with another actor so actor n2 have to change the velocity to the actor n1 velocity but in another direction.
How i can calculate the velocity of an actor? @armelline @the_gamesalad_guru @tatiang @socks

Comments

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    Vector to angle( actor 1 x - actor 2 x, actor 1 y - actor 2 y)

  • Andrea_ComisiAndrea_Comisi ItalyMember Posts: 328

    @the_gamesalad_guru that is to calculate the angle but for the velocity?

  • Andrea_ComisiAndrea_Comisi ItalyMember Posts: 328

    I would know what is the function to calculate the velocity of an actor ( it's for the air hockey style game with you helped me)

  • Andrea_ComisiAndrea_Comisi ItalyMember Posts: 328

    I want to calculate the paddle velocity so i can constrain the puck velocity to it

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited September 2014

    @Andrea_Comisi, you can use

    magnitude(self.motion.velocity.X,self.motion.velocity.Y)

    to get the velocity.

    It does the same as the classical sqrt((velocity.X * velocity.X)+(velocity.Y * velocity.Y))

  • Andrea_ComisiAndrea_Comisi ItalyMember Posts: 328

    Thank you @hopscotch i will test it as soon as possible

  • Andrea_ComisiAndrea_Comisi ItalyMember Posts: 328

    @hopscotch i can't constrain any attribute to the linear velocity because even if i constrain it to an attribute still be 0( i tried with integer real and undex)! Any solution? It wirk only if i unlock the prototype

  • Andrea_ComisiAndrea_Comisi ItalyMember Posts: 328

    And directly use te linear velocity of the actor trough current scene-layers....

  • HopscotchHopscotch Member, PRO Posts: 2,782

    @Andrea_Comisi‌, upon collision calculate the velocity of the first actor, pass the value to a game attribute and read it out in the second actor. Make sure your actors are either ordered correctly in the layers so that actor 1 gets processed first, or even better, wait one draw call before testing the game attribute.

    It is not quite clear what you are going for, maybe a screenshot or sketch will help.

  • Andrea_ComisiAndrea_Comisi ItalyMember Posts: 328

    I will use the unocked prototype is more simple

  • Andrea_ComisiAndrea_Comisi ItalyMember Posts: 328

    @hopscotch i can't upload anythink because now im using the my phone internet because i don't have wifi there's a black out

  • Andrea_ComisiAndrea_Comisi ItalyMember Posts: 328

    Problem solved

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    That's how I did my game.

  • Andrea_ComisiAndrea_Comisi ItalyMember Posts: 328

    @the_gamesalad_guru if i'm not wrong you used a change velocity bhavior but i wanted a ball that increase its speed if the paddle collide with it fast and decrease its speed if the paddle collide with it slowly and finally i got it, withh your method the ball collide with the paddle but the velocity is ever 1500.
    MANY THANKS FOR THE YOUR HELP AND FOR THE YOUR AVAILABILITY @The_Gamesalad_Guru and @Hopscotch

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited September 2014

    Just set a max speed value in the puck actor if you don't want it to go above a speed. Max speed value is in the list on the left window of the actor. Just check the box and enter a value.

  • Andrea_ComisiAndrea_Comisi ItalyMember Posts: 328

    @The_Gamesalad_Guru said:
    Just set a max speed value in the puck actor if you don't want it to go above a speed. Max speed value is in the list on the left window of the actor. Just check the box and enter a value.

    This can only limit the velocity. With the @hopscotch method i create a more realistic bouncing of the puck in the paddle. Now the problem is solved so this discussion can be closed

  • Andrea_ComisiAndrea_Comisi ItalyMember Posts: 328

    @BlackCloackGS can you close this thread and why the my last post is yellow?

Sign In or Register to comment.