Hello guys
I’m creating a software where objects dragged by the mouse move and connect to each other via sockets.
How can I prevent these objects from intersecting each other and above all how can I prevent these objects from intersecting, for example, walls within the game space?
what I would like is that if these objects are dragged onto a wall they freeze, as if there is a collision.
When the OnCollision function is called, you can check what you hit and also perform some logic to freeze the moving object. For example:
void YourMovingObject::OnCollision(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
if (OtherActor->ActorHasTag("Wall") && !frozen)
{
// If the other actor has the "Wall" tag, freeze the object
frozen = true;
StopMovingAndFreeze(); // Your code to stop stuff here
}
}
Note that how you actually freeze your object will depend on how you moved it in the first place.
Many thanks
I have don this, I set “hit simulation” and “gravity” to the hit box, I set the tag on wall actor and add a “print string” to show me the result, but nothing…
Wall actor have a “root component” and a “static mesh”, I set the tag to both element
It’s hard to understand how things interact if we can’t see the whole picture. A screenshot of the Details panel of the moving object and the wall would help.
There are actor tags and component tags. Which one did you set? In this case, only the actor tag of the wall needs to be set.
Try adding a debug statement after the On Component Hit node to see if the issue is with the event being triggered, or if it’s something further down the line in the logic.