Try having simulate physics Off, change collision type to block all, and simulation generate hit Events on. In the enent graph, make a hit event that adds impulse at location
My projectiles ignore walls and floors (both BSP and meshes) but I want them to collide with those so that they can bounce off of them.
Some things I tried (may differ from screenshots):
- Simulate physics: unchecked
- Generate overlap/hit events: checked (this should not be required though but just in case)
- Tried with BSP and Mesh.
- Checking âsimulate physicsâ will cause the projectiles to fall flat to the floor, but it does NOT go through the floor. It actually collides with the floor but this behavior is obviously not very useful for a projectile.
- I made the Mesh a child of the collision component (should not be required but some people say it is).
- I tried using a custom Projectile âProfile Presetâ and âObject Typeâ but didnât work either (same result obviously).
- There is no code in the blueprint that affects collision. Only an event that implements the OnComponentBeginOverlap.
- Tried various collision presets but none worked.
- Projectiles DO COLLIDE with enemies and players and also generate OnOverlapEvents. Just not with BSP and static meshes.
- I checked the default starter FPS Projectile but couldnât find any difference with my projectile.
- I tried setting the CollisionSphere to âBlockAllâ, I checked the âBlock Allâ collision profile and made sure it actually does block everything. Still does not work
- I rebuild the level
- Added more collision boxes and spheres to this projectile and set them to âBlock Allâ.
- I am out of ideasâŚ
My settings (click links at bottom of post to enlarge):
I created a quick custom mesh and added a HUGE floor collision box. But projectiles still go through it:
I did all that (for both the mesh and the SphereCollision). I also added the impuls (but it never fires). The onhit-event is never fired not even when the projectile is in the middle of a wall-collision. I may have coded the impulse wrong I think but nonetheless it doesnât even fire.
In the picture it says block all dynamix, change the collision sphere to Block All. And the mesh to no collision. The mesh is just there to look pretty.
Yes and I did as you wrote me (I changed it to block-all). Still doesnât work. I even added more collisionboxes and spheres and set them to block-all and checked âgenerate on hit eventsâ but they go straight through everything except for other pawns⌠Which is weird. And generate no onhit-events which is also weird.
Iâm getting this feeling that something somwhere is overriding something to make it only collide with pawns and with nothing else. But when I add a printstring to the âGet Collision Profileâ it prints âBlockAllâ during runtime so the profile is set correctly and not overriden anywhere. Still it only collides with pawns. So I checked the âBlock Allâ profile but it is setup correctly (blocks all).
So basically I have a projectile (inherits from actor) with multiple collision-components that all are set to block-all and âgenerate hiteventsâ checked. And yet they go straight through meshes (with collision) and BSP w/o firing any onhit events nothing. How is this even possible?
Yes I hit compile+save after making any changes. Yes I did rebuild the level just in case.
I also tried a new âprojectileâ:
- Created new blueprint derived from Actor
- Added a ProjectileMovement component
- Set the initial ProjectileMovement speed to 100
- Added a cube so I can see it in the world
- Added a collisionbox and set it to âBlock Allâ and check âgenerate hit eventsâ
- Drag the cube into hhe level in front of the playerspawn
I run the game and I see the cube falling through the level straight awayâŚ
Could it be that the ProjectileMovement component is making the projectile move regardless of collisions? But it still wouldnât explain why onhit and overlap events are not firing.
After some more Googling around for this âon simulate physicsâ checkbox (note that both questions did not get answers with a solution other than workarounds):
It seems that the moment you do not simulate physics, ALL forms collision detection will break/cease to exist other than pawns. Is this a bug?
I managed to somewhat get it to work by checking âsimulate physicsâ and unchecking âenable gravityâ but this MUST be performed on the MESH component. Which is silly because the collisionboxes themselves still do not work, only the mesh can. And the mesh is supposed to be a visual only normally.
I also took the FPS project (with a working bouncing ball) and copied itâs mesh, projectilemovement and collisionsphere into a new actor-blueprint. So now Iâm 100% sure I got it all setup right. Still it falls through the floor. So itâs not the settings in the detail panels the difference has got to be somewhere else.
Also I noticed that the FPS project has no SceneRoot component in the projectile. But I can not delete mine. I assume that the default project was upgraded from an older UE4 version that allowed not having scene-roots.
I copied the âFirstPersonProjectile.uassetâ from the FPS sample into my project and rebuild it into my new BaseProjectile. I still have absolutely no idea why that one works and mine doesnât since I canât find any difference between the two blueprints aside from having a SceneRoot component (which I canât even delete).
I would still like to know though what I and all those other people did wrong. Because not one of these posts I could find anywhere on Google had an actual answer other than some silly workaround. Meaning nobody knows?
Secondly: Why does unchecking âsimulate physicsâ also prevent collision-checks including overlaps? Intended?
I found the problem! Might be a UE4 bug. Apparently the moment I ctrl+x the SphereComponent from the FirstPersonProjectile and paste it back (this creates a scene-root so the sphere collision component is no longer the root) breaks it entirely. Only applies to actors that have the âsimulate physics everywhere uncheckedâ. So the CollisionComponent MUST BE THE ROOT in the actor-blueprint and when not, ALL COLLISION (except collisions with pawns for some reason) is gonna be ignored by the game for this object. I reproduced it across several projects. If Scene_Root is the root (which is default) it will break.
Sadly you canât override the Scene_Root in a child-component⌠Man this whole thing is so weird I dunno why they implemented the Editor to work this way. So you gotta put in a dummy-component instead of the default-root, then replace it in the child in the constructor with the real thing. Only then can you replace itâŚ
Note that adding additional collision-components does NOT work (only the root-collision-component works).
Because of this insanely weird behavior my guess is that this is a bug.
Yup, what you described after âI found the problemâ was the only thing that worked for me too. I added a collision sphere, and dragged it over the scene_root, which replaced it and then it started working.
When actor have DefaultSceneRoot you need to âSet Updated Componentâ in ConstructionScript. By doing this âProjectile Movement Componentâ will update the âCollision Componentâ other than DefaultSceneRoot ,then Collision will work!
this solution actually works.
thank you so much for this answer, i was struggling a lot