I have issues with collisions in my last project in UE4.19 and i can’t really know where it’s going wrong. I fully understand the channels and how it’s supposed to work but the fact is that i get exactly the opposite of what i try to achieve. So i’ll explain a bit.
The project is a top spaceship game with a camera attached to the pawn. The Z axis is fixed and every projectile is clamped to the remaining plane to ensure they collide with all the space ships.
So this is a bit the first difficulty, when the projectiles are shot, sometime they collide with the instigator and i’m looking for a way to deactivate the collision for maybe 0.1 s time it’s out of the collision box and activate it then. But it’s not the real big issue i get.
So i have a few channels used for collisions, one for pawns, one for explosions and energy based projectiles and one for solid projectiles.
My pawns do collide with each other normally (Even if they bounce what is ridiculous … But right at least it works).
My rockets are stopped by other rockets, but not by pawns …
My plasma bolts (Energy) pass through every pawns except the one that shot them.
When my rockets are out of fuel they explodes, spawning an actor that materialize an explosion, with a radial force and a particle. They do collide with plasma, with rockets, with AI pawns, but not with unpossessed player pawns.
At this point i don’t understand anything about how it is supposed to work all seem really random to me.
A bit more about the architecture.
I have a class “spaceship” that inherit directly from pawn. AI ships are from this class, then i have a “playership” class that inherit spaceship and manage a few features that only players would do. All those classes have a static mesh as root component that simulate physics and have simplified collision set via UE mesh editor.
For projectiles it’s a bit the same. I have a “baseprojectile” that have two children Eboltype and Rocktype. Each of those classes have a static mesh as root and a projectile movement component as root too. Don’t know why it’s like this, i can’t move it anywhere else.
My pawn channel block all except worlddynamic
Projectile ignore worldstatic and world dynamic, overlap energybody and block the rest
Explosion ignore worldstatic, worlddynamic, energybody overlap physics body and block the rest
Energybody is a channel i created.
So i just don’t understand what is wrong and why it collide with only one pawn, the one i controle and ignore all the rest in most of the cases.
Well no answer?
I tried to tweak everything, turn on and off physics it seem to change nothing at all, i’m blocked in my development cause of this. I looked everywhere for something like this and can’t find anyhelp.
Too much text, no screenshots. Just post screenshot of the collision settings of the pawn, the projectiles, and the collision detection logic you have done.
How do you detect the collision? With overlapping/line trace or? The problem I am almost sure is from messed up collision responses/channels.
Alright here it is, the two channels used for my pawn and projectiles. For the logic in the blueprint i use onhit and onbeginoverlap events. None are working for projectile to pawn collision.
Hmm, I can see that on your projectile you have turned the “CollisionEnabled” to No collision, which mean this projectile will never be detected. I assume at you dont want the projectile to collide (physically) with the main actor/other actors, pick the "Query Only (No physic collision). That way the projectiles will be always detected on the corresponding collision channels. If this is not working then you should also post a screenshot on your overlapping logic.
As you can see on the logic in the blueprint i set them on collide physics and query in the event begin play, allowing it to activate collision once they are no more overlapping with the the instigator.
Ok, can you post the detection logic you have made? As you can see I am trying to help you, I cannot help you without you providing the necessary information…
That’s on the screenshot actually you have the begin play, the 2 channels i am trying to make work together and you have the props window of my projectile.
But fine, i post the logic of my rockets, what will not help much as they don’t generate the hit event like i said, nor the begin overlap with pawns.
And as i said two rockets do collide fine with each other.
I get you but I need to be sure that the problems doesnt comes from your detection logic. Ok, on your projectile collision settings, check the Pawn overlapping checkbox inside the ObjectTypes and now everything should work.
This doesnt surprise me at all, I dont have a lot free time today so, here is a checklist from me for you to go through everything to find the source of the problem:
1 - Does projectile component has collision? You can check this by going to the mesh editor and check if there is any collision, or you can add the actor to the scene and use the alt-c combination to see if a wireframe will popup (its the collision wireframe). If it doesnt popup so the projectile doesnt have collision.
2 - Does the enemy ship has collision? Do the same steps that I described in point one.
Possible solution to the collision problem is to use the Capsule, Sphere, Cube collision bp components instead using the mesh complexity as simple collision.
3 - If you have the collision checked or remade the collision, could you check all the channels to only overlap and not block? Also make the objecttypes (dropdown menu) to be the same for both the enemy ship and the projectile.
Now everything should work and the next step is just to use simple conditions to check if the actor collide with another actor or you just can continue from there with your logic with the custom channels.
Again, 1 and 2 are multi checked like i said, ships do collides with each other. Projectiles do collide with each other. Projectiles do collide with the instigator, but projectiles do not collide with other pawns.
So yes my collisions are set correctly, or i would have none at all.
What you are asking me is to remove all collisions, stop using physics and then tell me “all should be fine”. No sorry it won’t be fine, i want the physics in ships to ships collisions. I want to be able to make bullets bounce on the plating of my ships if angle is too large and i couldn’t have it with overlap. I would add that overlap don’t work better than block. On my tests if blocks do not works, turning the channel to overlap don’t work either.
I would add i tryed to shot a rocket that spam the sphere overlap in the tick event and it did not return my pawns either. It’s just like the unpossessed pawns are totally invisible for my projectiles no matter what i try, and they are only invisible for my projectiles.
Actually not, it was just for a debugging purpose, if everything works well then you can just simply continue working by changing the channels you need to block.
Lets continue then, (if you did what I asked you to do and still it didnt work) Could you post a screenshot on how you did setup the pawn? Just show me the components inside the blueprint.
The first class with only a static mesh as root in the viewport is directly a child of the pawn class. The ship i have posted then is child of this class.
I think maybe there is an issue with changing the static mesh in the child class as it is extended. Don’t know if it can be the issue, will check this when i have 2 minutes, but once again, as the instigator do collide i’m not really sure this could be the issue.
Its really difficult for me to find the problem you have with only screenshots. When I was learning UE4 2 years ago I had a lot problems with the collisions because its not that intuitive and in most of the cases I only thought that I had collision on the meshes.
Today I make sure that if i am going to use collision based logic, I import the static mesh with Auto Generate Collision and then I make sure that the **Collision Complexity **inside the mesh editor to be **Use complex collision as simple **because I dont want to have some random simple generated collision mesh.
The next thing I make sure that if I will use overlap logic I make sure that the checkbox **Generate Overlap Events **is checked and then I select the same object responses for both overlapping actors.
If I am going to use line trace, I make sure that the Trace Responses inside the collision settings block the channel I want to trace.
Did you try to have the same object type for both the rockets and the pawns? Try with WorldDynamic and have the overlapping on WorldDynamic for both actors too.
Well i looked a bit around and when i set my rockets on block all, they almost behave normally, i mean they do collide with pawns that are not the instigator. But it don’t solve my issues, even if i think it makes me progress a bit.
I think i found the issue.
When i set the channels from the beginning and don’t change them, it’s working almost fine, at least i got the collision between pawns and projectiles.
But when i modify the channels during play it seem to mess everything up and they don’t want to collide anymore, it’s a really strange behavior and really buggy to me. I can’t make it work while apparently it should simply work.
Will try to mess a bit more with it today, if i can solve the issue or get more clues will post.
Edit : Ok i’m pretty sure it’s bugged, i don’t know what but the behavior of my projectiles if i set them on “block all” or on my projectile channel change completely, while they are almost the same and it should change nothing at all. I don’t know what exactly is the issue but i will post in the bug report i think.
Alright, some update here, i cleaned some mess that was interfering with the issue, it did not cleared it but make things more visible.
So i want to go back a bit to what i said, setting the projectile on block all to not make it collide with pawns either.
I set the collision to overlap all to check what it was overlapping, and it overlap with my arena walls, with other projectiles of anytypes but once again, couldn’t get any reaction from my pawns.
It’s really confusing, it’s almost if pawns were invisible for my projectiles.
I tested the pawns again separately and they do generate hits with other pawns and the arena walls.
Hmm, If you want you could send to me only the bp pawn and the bp rocket (only with the components - no code). I can check this thoroughly and report to you the problem.