What can I use to the a ball to travel along a fixed angular velocity?

Hello, i have a problem.

In my game, i want a ball to move with fixed velocity. I managed to do this in these steps:
“Get Velocity”->“Normalize”->(multiply by target value of velocity)->Multiply by “Get World Delta Seconds”->Get World Transform, break it->Add the new velocity to the previous location->“Set Actor Transform”

This works, but i have an issue with weird collision reactions-i doesn’t bounce straight off the wall, it changes the direction(seems random). I suppose its the fact, that the ball is rolling on the ground and gets torque(angular velocity).

My idea of solving this was to use the “Set physics angular velocity” node. But i have no idea what the “New ang vel” should be. I tried to set it to cross product of the new velocity and up vector, but it didn’t work. btw. I have friction set to 0, shouldn’t it prevent from gaining torque?

Any ideas how to solve this problem? Perhaps i should uncheck ‘simulate physics’ box, and do all the physics for the ball myself?

The intention is:

So that the velocity is corectly reflected off the surface, without any contribution of torque.

If you’re trying to set the angular velocity so that it doesn’t move, it’s simply just 0 for all axes

But i don’t want the ball to just stop. I want it to keep rolling and have fixed velocity(both linear and angular), not zero though. :slight_smile:

Alright I get yah, so what I would do is that get the hit normal and make the direction go that way, but then I don’t know how to do that in angular velocity honestly :frowning: I’ll try doing some research, if I figure something out, I’ll get back to you lol

What I actually did was unchecking ‘simulate physics’ option. This way i have to detect and handle all collisions with non-physic objects myself. Collisions with physic objects are detected(OnHit event) and I just have to reflect the velocity. :slight_smile:

There are some minor issues with that approach(sometimes there are weird reactions to collision), but it’s acceptable.

+I cannot set friction to 0 on all surfaces on the level, because apart from the ball I also have physic objects which I want to behave correctly.

You need a material and for that a physics material for all of your surfaces! There you can turn off friction. Set your ball’s gravity to zero and perhaps angualar and linear damping. There is also a physics component for actors, but I’m just trying that out by myself…

I’m now at the point where my ball doesn’t stop anymore and reflects relatively properly. The problem is, it gets too fast sometimes and the collision solver just gives up and my ball vanishes out of the field into the dark…

Can you maybe post your BP for that? I’m very curious how you’ve done that. I’m trying to invert the velocity by myself but I think I need just a small hint for understanding how it works.

Actually i have done it in c++, but in bp it would be the same. For a vector there is a function ‘MirrorByVector’-in “On hit event” just mirror your velocity by impact normal and it will work just fine. :slight_smile:

like:

void ABallActor::OnHit(AActor* SelfActor, AActor* OtherActor, FVector >
NormalImpulse, const FHitResult& Hit )
{
Velocity=Velocity.MirrorByVector(Hit.Normal);
}

(dayum, dat formatting :smiley: but it should be clear anyway)

In general, that function uses a simple formula involving dot product-given the surface normal it ‘bounces’ a vector off the surface(quite as shown in the picture in the first post here)

Hey Oti,
Did you ever get this to work in blueprint format? I was actually looking for similar functionality. If you got this to work, any chance you can post a screen shot of the blueprint for a simple object?

Any help would be appreciated, Thanks