## Making a door hinge

Moderators: cry-nic, Community Volunteers

### Re: Making a door hinge

#11
check
Attachments
3.png (1.18 MiB) Viewed 396 times
2.png (1.14 MiB) Viewed 396 times
1.png (1.15 MiB) Viewed 396 times

### Re: Making a door hinge

#12
Ohhh man you are using a point constraint not a line constraint! Holy crap it finally works!!! This is the code that ended up doing the trick for me!

Code: Select all

```Matrix34 entityTM = m_pEntity->GetWorldTM(); IPhysicalEntity *pPE = m_pEntity->GetPhysics(); pe_action_add_constraint ac; Vec3 axis(0, 0, 1); ac.flags = world_frames | constraint_no_tears; ac.pBuddy = WORLD_ENTITY; ac.xlimits[0] = DEG2RAD(-90.0f); ac.xlimits[1] = DEG2RAD(90.0f); ac.yzlimits[0] = 0; ac.yzlimits[1] = 0; ac.pt[0] = ac.pt[1] = entityTM.GetTranslation(); ac.qframe[0] = ac.qframe[1] = Quat(entityTM) * Quat::CreateRotationV0V1(Vec3(1, 0, 0), axis); ac.damping = 0; pPE->Action(&ac);```
Things that I was also misssing was:
yzlimits[0] and [1] needed to be initialize to 0
xlimits[0] and [1] are in radians not degrees

Thanks so much for hanging in there with me on this!

### Re: Making a door hinge

#13
Hello,

I know I come a little bit late to the party But I just wanted to mention that we added plane, point and line constraint components to the engine. You should be able to build the same sort of door with those components without touching much C++. I just gave it a really quick try and will show the result below.
door.gif (3.1 MiB) Viewed 381 times
The entity consist out of a mesh component, rigid body component and the line constraint component. I just tweaked around with the attributes until I got the desired result.
setup.jpg (162.08 KiB) Viewed 380 times
Cheers,
Alex
Attachments
setup.jpg (162.08 KiB) Viewed 381 times

### Who is online

Users browsing this forum: No registered users and 1 guest