x

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"

Enabling and disabling physics problem

Hello all,

So essentially I've got a game where you have to reflect a ray of light using mirrors (dynamic lighting). To do that, you pick up 'F' mirrors and rotate them on different axis (X & Z). When done and the mirror is in the right position, you drop the object 'F'. The problem is, because I can tilt back the mirrors for example (they're cubes), as soon as I drop the object they flip, as affected by gravity - so they fall over.

I have 'Pickup object' and 'Drop obj' as custom events, so I've enabled 'Simulate physics' when picked up and disabled upon dropping the mirror, which does it - freezes the mirror cube in place as it's not affected by physics anymore.

Problem is, when I pick up another mirror object, physics apply to the previous one again - because the enable / disable simulate physics is all done under the linetrace node inside the character blueprint. Which means I am enabling and disabling the physics of an object only for as long as linetrace triggers a hit event. //Grab mirror #1 -> the hit object is mirror #1 -> rotate it, drop it -> object #1 frozen in place, physics disabled, all good. Grab object #2 -> hit object is now mirror #2 => Object #1 is no longer the hit object, so physics are re-enabled, object belly flops.

So I've created 2 more custom events - 'Enable physics' and 'Disable physics' in the mirror's blueprint in hope it will directly affect the objects' physics. When picked up, it calls 'Enable physics' from within the objects' bp. Same when dropped, disabling physics. alt text

Now, I obviously needed an object reference 'Reflector' that references the mirror object when the event calls in the Player blueprint. Thing is I have absolutely no idea how to set that variable and where.

And to be fair, any kind of solution would do, no matter if different - I just want to grab a mirror /10, adjust it, drop it and it stays in that position. Grab mirror #2, mirror #1 still frozen in place. And so on and so forth. Axis constraints maybe? but that wouldn't allow me to rotate the objects.

Any help would be greatly appreciated. Thanks! alt text

(I am sorry for the spaghetti code.)

Product Version: UE 4.21
Tags:
set-reflector.png (131.3 kB)
cast-reflector.png (313.8 kB)
more ▼

asked Apr 01 '19 at 12:56 PM in Blueprint Scripting

avatar image

OutOfRehab
9 1 3 5

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

0 answers: sort voted first
Be the first one to answer this question
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