Can you make the box collision grow on any axis in one direction only?

@runtime, If I have a box collision that goes from X 0 to X 100 and I want to increase its range to X 0 to X 200, do I have to resize the box extent + recenter the whole thing to get the result or can I make it grow only on positive X?

box

I think Zvenzo meant having it grow only away from the camera, with the side nearest the camera in your image remaining in place.

And if I understood the question correctly… realistically, yes, you’re going to have to grow and re-center it. (Or you’d have to create a new type of collision box where the origin can be shifted at runtime, which would be more work to get basically the same functionality.)

It should be pretty easy, though. As you grow the box in one axis for each step, just move it the opposite direction by half the amount you grew it. If it grows by 1 unit, move the box itself by -0.5 units. If it grows by 10 units, move the box itself by -5 units. Etc.

Bundle it into one function – and use a timeline and a lerp operation as in ClockworkOcean’s reply – and it’ll grow smoothly like that while also shifting the origin to ensure it only grows away rather than outwards.

1 Like

you understood me correctly

jeah thats what I thought. Not an issue though, I just wanted to make sure there isn’t a functionality hiding from me. Thanks :slight_smile:

Exactly the same code, just move the pivot point to the end :wink:

shiftedpivot

image

thanks clock, I’m aware of that but in this case its really just an actor containing a single box collision. No mesh, nothing.

You could use a mesh for the collision I guess. I haven’t tried it.

Make it invisible and change it’s collision to overlap all.

1 Like