Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How do I prevent my physics constraint from drifting?

I'm doing something like a noisemaker you hold in an FPS. Reference: alt text

I create the stick handle part you hold.

I created the rattling head as a separate game object.

I attach a Physics constraint to the handle and position it where I want it. Then I set the two actors: handle as actor 1, rattler as actor 2.

Linear limits are all locked

Angular limits are locked except for twist (so that the rattler rotates on a single axis)

Linear motor is off

Angular motor is off

Projection is off

I turn Physics on on the rattler, and collisions to only hit static environments. I rather collisions be off, but if I do that, the rattler doesn't attach to the handle at all.

Problem: when I translate in the game left, right, forward or backward, you can see the rattler drifting a little bit positionally (as if on a small spring). Other than that it works as expected.

Questions: How do I remove the drift? The rattler should be solidly on the handle only rotating on one axis as you move around.

Side question: Is there a way to have collision off on the rattler and have the physics constraint still work?

My educated guess: The FPS player is updated during the physics update, then the gun is put on the hand post physics update. Since the physics constraint does its thing during the physics update, and places the rattler on the handle during it, the rattler ends up a frame behind.

Possible Fix: Don't use a physics constraint. Place the rattler on the handle myself in a tick post physics. Apply forces proportional to the world location and rotation delta of the rattler from frame to frame. Attaching one actor to another (using AttachTo) turns off physics on the second actor automatically, so I have to attach it myself in code during the tick. Can anyone think of a better way?

Product Version: UE 4.8
more ▼

asked Aug 30 '15 at 08:14 AM in Using UE4

avatar image

1.4k 46 44 209

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Have you tried turning projection on, with a low tolerance? That should keep the head from moving away from the handle. I had had a similar issue ( one of the contrained actors moving where it should not ) and projection helped.

more ▼

answered Sep 11 '15 at 11:44 AM

avatar image

41 2 4 7

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

You should try to use only swing1 or swing 2, so just one of them. I guess its just swing1 you need so it allows turning on the xy plane which should be Yaw. Hope that helps. Cheers.

more ▼

answered Jan 18 '18 at 09:18 PM

avatar image

1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question