Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
666 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 Reply

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...