• News

• Industries

• Learning & Support

• Community

• Marketplace

# Understanding paper2d or how to build a polygon collision?

Hi
Long atory short i am trying to use spine 2d on ue4 and s the plugin is very limited so i wrote my own.
The spine plugin builds a mesh ever fps uaing rmc.it works fine.
The thins is i need collisions. Using rmc with collisions is very expensive. Because the mesh is building every frame.
So ibwas looking how resolved it on unity. Spine can create a set of collision polygons so in unity they build a collision polygon with it and then make it folloe the bone.so the set of polygons is built once and the they just follow the bone position and rotation.
In ue4 i dont know how to build a collision polygon of n vertices. So right now my solution is create plane meshes polygons using rmc for each bounding box polygon for spine and make them follow the bone every tick with setvlocation rotation. At the beggining work sometimes but fps go down and rmc.dont collide each other all the time.
My solution now is on every tick on each actor i call get bounds for each mesh created and i use fbox for each one and check the fbox overlap result.
The problem is that it limits the colliaion are to boxes because get bounds and doesnt work for raycast checks.

So now i am looking at github ue4 to see how they made it with paper2d and polygons collisions. So far i have understand they use physx and box2d as optional.

So i would like to know(to resume sorry) how can i convert a polygon composed of a list of vertices without an index buffer and convert that into a collision polygon that can be moved ans rotated following a moving object using physx.

So, the typical path for getting collision is to assign a ShapeComponent (Box, Sphere, or Capsule) to the pawn and to use the collision from that. As far as I know, you can use multiple ShapeComponents on the same pawn. If you built your collision out of a series of these shapes, you could probably build your MovementComponent so that it moves them appropriately? (Following the bone, in your case)

If boxes, spheres, and capsules aren’t good enough, you could look into UShapeComponent and building your own n vertice shapes. I haven’t touched it before though, so I don’t know how extensible it is.

ok looks like Ushape is the class that i am looking for, but i dont understand how can i set it up to shape it like i want.

if i have an array of points in space how can i pass those points to the ushape component and build that geometry?

Unfortunately I haven’t used it before. My advice would be to poke around CapsuleComponent’s code and see how it uses ShapeComponent. Maybe start at CapsuleRadius/CapsuleHalfHeight and see where they go.

the problem with capsule is that they use macros and constants designed for those primitives. sames a cube and sphere.

Can someone of the epic staff give us some guidance about this problem?

Up!

waiting for