Announcement

Collapse
No announcement yet.

Angle math question.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Angle math question.

    Say I'm getting a angle read from camera. I am at those point making an effect of in range of player and in range. It deflects. But I want to set the projectiles velocity to deflect as if a radius.

    So imagine a sphere is around character and your blocking a projectile but not looking directly at it and because we can assum slight of center is slightly center is a different normal. For instance
    Your looking straight ahead and object comes in at you at 45 degree angle it would bounce back the at it came if objects velocity was true center to your center because a radius is a radius.

    Help me solve this math of getting the forward vector and dot prod of object vs player to ensure it defects correctly.
    Inphidel / Brian - Developer of Ultraball
    http://www.ultraballgame.com

    Don't shy away from bugs in your game. Don't play it as intended. Break your game so you can fix it!

    #2
    Wait think I know. Like a get look at rotation at point of event to object and use that rotation to change velocity
    Inphidel / Brian - Developer of Ultraball
    http://www.ultraballgame.com

    Don't shy away from bugs in your game. Don't play it as intended. Break your game so you can fix it!

    Comment


      #3
      No wait cancel that. It would only return back the way it came and not allow a glance deflection.
      Inphidel / Brian - Developer of Ultraball
      http://www.ultraballgame.com

      Don't shy away from bugs in your game. Don't play it as intended. Break your game so you can fix it!

      Comment


        #4
        Originally posted by Inph1del View Post
        No wait cancel that. It would only return back the way it came and not allow a glance deflection.
        I'll leave this to someone more qualified, but just add a small suggestion.
        Games are as much about artform as science especially when prototyping.
        So maybe try Teleporting a mesh in front of the player at different angles...
        Use a more empirical approach first to gauge if its really what you want etc.
        ----------------------------------------------------------------------------------------------------------
        What are the BEST Unreal Tutorials / Docs? There are none tbh... Here's why
        Instead its better to just take projects apart (see the free 'creators' listed here)

        Comment


          #5
          Originally posted by Inph1del View Post
          Say I'm getting a angle read from camera. I am at those point making an effect of in range of player and in range. It deflects. But I want to set the projectiles velocity to deflect as if a radius.

          So imagine a sphere is around character and your blocking a projectile but not looking directly at it and because we can assum slight of center is slightly center is a different normal. For instance
          Your looking straight ahead and object comes in at you at 45 degree angle it would bounce back the at it came if objects velocity was true center to your center because a radius is a radius.

          Help me solve this math of getting the forward vector and dot prod of object vs player to ensure it defects correctly.
          Here is how I would approach it:

          Use a sphere trace on your character and specify the desired radius. On Hit, break the hit and get the Impact normal. Now you can rotate the projectile using this normal and "deflect it."

          Alternatively, you can use an invisible mesh and use the OnHit event. You can break the hit and get the normal as well.
          [WIP] Procedural City Generator | RPG AI
          [MARKETPLACE] Animal Behavior Kit | Space Shooter Template | Procedural Foliage Tool | Procedural Park
          [FREE] Modular Road Tool | Action Platformer Template | Radar BP | Free Birds | Procedural Buildings
          Join our Discord

          Comment


            #6
            Ok I've got something in the works already that's seems to work. Since this is a projectile it doesn't function exactly like a physics object.

            On overlap I check to see if the dot is positive or negative so I know if I'm moving away or torward projectile. Then if moving away I use the look at rotation from player to projectile and use that forward vector plus length of its own velocity. If moving at the object I choose between players length or projectile length depending on what is greater. This allows a slow moving object not to deflect slower then the player is moving.
            Inphidel / Brian - Developer of Ultraball
            http://www.ultraballgame.com

            Don't shy away from bugs in your game. Don't play it as intended. Break your game so you can fix it!

            Comment

            Working...
            X