• News

• Industries

• Learning & Support

• Community

• Marketplace

# 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.

Wait think I know. Like a get look at rotation at point of event to object and use that rotation to change velocity

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.

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.

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.