2 actors, a turret and a ship, attached together. How do I stop the turret from rotating(set actor rotation) when it collides with the part of the ship. Right now, when the turret collides with ship, the whole thing flies away.
If the turret mesh has a collision, you can use Event OnActorBeginOverlap to receive the information it has started colliding with something
Is it a child actor or an attached actor? You should probably make the turret a child actor, and I think it’d avoid collision/flying away problem
Barring that, check their collision, and make sure that both are set to block each other.
If they’re set to blocking each other, and are child actors, and still doing this, that’s strange, but you can put a gate on your Tick leading to the turret code, and close the gate on Event Hit for the turrets, if it hit the owning carrier.
Also, another thing that’s worth doing that I do for my turrets, that might avoid this problem entirely, is setting up a hit trace for their targets.
My turrets are constantly tracing the primary target. If the trace fails, and/or it hits the host ship, it ignores that target and checks for another if one exists, otherwise it does nothing.
This will prevent your turret from aiming into your ship entirely, which will still be a problem even once you fix the collision/flying away issue. It will still want to aim at targets it can’t see.
Another option is putting a clamp on the turrets rotation so it can’t rotate past X degrees, and setting X to whatever degree the turret can rotate too without sliding in the ship. This is the easiest but laziest method. I recommend the tracing method.