Jump to content
reepblue

Vec3 Bounce Reflection

Recommended Posts

Hi All,

I'm hoping somebody who's a bit better at math may be able to help with this. I'm trying to get math down for reflections off a surface based on the direction of the entity.

My current code which pretty much does the same thing as aligning the entity to the surfaces normal.

		auto contactnorm = tr.vNorm;
		auto rot = GetEntity()->GetRotation().Normalize();
		auto newDir = Vec3(contactnorm).Reflect(rot);
		GetEntity()->AlignToVector(newDir, 2);

I would appreciate the help.

  • Like 1

Share this post


Link to post

It is very strange that you are treating rotation as a vector. Instead you probably want to transform the vector 0,0,1 from entity to global space.

Share this post


Link to post

The AlignToVector bit was due to success of the ball bouncing off with the normal of the surface as it's new direction.

Thanks. I'll try again with Transform::Vector().

 

Share this post


Link to post

Using the direction of the surface is fine for right now and the bouncing implementation seems more work than for what it's worth. I'm probably gonna come back to this if I decide to add reflection lasers, and I think that'll be easier to implement.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...