Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
634 views
in Technique[技术] by (71.8m points)

collision - Eject Blocking Object if Overlapping: UE4

My 2d platformer has a "time travel" mechanic. You place down a hologram at a location (actor with no collision and some pretty effects).

While you hold down the "Rewind" button, your character's collision and gravity are turned off, and he slowly moves towards the hologram.

When you release the rewind button, it turns his collision back on.

My tilemap is set to "block" the pawn (so he can walk on it, etc).

If you release the button while he's overlapping the terrain, and it turns his collision back on, he gets stuck.

I'm wondering what to do. Unity automatically "ejected" an object that was overlapping something it shouldn't be.

Since the terrain is set up to block the pawn, I can't fire an overlap event. "On Component Hit" will fire just from him standing or rubbing against the terrain, so that won't do either.

How should I detect that the player is popping up inside the terrain? I can decide what to do later (eject them, kill them, prevent them from appearing, etc). But for right now I just need to differentiate from them touching the tilemap and being inside it.

Any ideas?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

So what I wound up doing was duplicating the capsule collider on my player. The new capsule (called 'Terrain Overlap') ignores all collisions, except it overlaps the tilemap.

The component has a begin and end overlap method that sets a boolean on the character.

When the player lets go of the Rewind button, if they're inside the ground (boolean check), I can fire the death method. Ultra simple blueprint


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...