Automatic Fix for The Door Rotation (Lesson 91)

Hi there, folks!

I’ve been enjoying a lot te course, although I already know and work with Unreal. Knowing some things about blueprints, I wanted to present some insights about the problem with the door rotation in Lesson 91:

  • Blueprints are supposed to work as templates, in the same way as classes for C++: when creating a Blueprint, is best pratice to create a generic solution that may work and adapt itself to many other cases than creating something really specific and trying to correct bugs that appear when its used on different contexts.
  • Sometimes its easier to work with the components than the actors themselves.

So, that being said, I initially created my BP_Door to include the door frame as the root object of my blueprint and attach the door to the door frame later. This way I can rotate it based on a relative rotation to the door frame.

Like this.
And here is the Blueprint.

Notice also that I exposed two other parameters:

  1. The Opening Angle, that holds the max angle the door will open. My Timeline goes from 0 to 1 and than is multiplied by the Opening Angle, allowing me to open the door to any angle.
  2. The Door Close Delay (needs a better name, this variable) that holds the time (in seconds) it takes to close and open the door. After exposing it I just have pass it as it’s inverse ( 1 / DoorCloseDelay ) as the parameter to the Set PlayRate node and now I can have multiple doors that take different times to open.

like this:

end result

and this is the way to expose to BP:

// By adding them as UPROPERTY with the BlueprintReadOnly argument
// I can see them in Blueprints

UPROPERTY(EditAnywhere, BlueprintReadOnly)
float OpeningAngle = 90.0f;

UPROPERTY(EditAnywhere, BlueprintReadOnly)
float DoorCloseDelay = 1.0f;

Hope it helps,

Cheers!

3 Likes

Thanks for sharing. This is great work.

That’s nice, because now, I can have the value of the openedDoorAngle differently for each door. And in blue print, instead of using the timeline to decide the value of the angle, I can put a percentage of opening (0 to 1).

I challenged myself to add OpeningAngle to my C++ code and BP. Adding it in C++ was easy (using the example above), I also saw it in BP as property, but I couldn’t figure out how to use it in Event Graph. You couldn’t see the variable under variables.

Following trick helped:

  • close UE, rebuild it in VS (I don’t know if it was necessary), open UE again
  • Right click in EventGraph, unclick Context Sensitive and search for Opening -> you should see Get Opening Angle
  • Add it to the Graph
  • Add also Open Door and link it as a Target

Thanks for the idea!

Hello I have a few question about your Blueprint Code

Ask away. I’m all ears.

here is my solution

I have this code in my “opendoor.h”:

UPROPERTY(EditAnywhere, BlueprintReadOnly)
float DoorCloseDelay = 1.0f;

but I can’t fine DoorCloseDelay in my Blueprint as a variable. therefor i create Door delay variable in Blueprint and make soultion like this.
How do you use DoorCloseDelay as a variable in Blueprint
2) while I switch off Open Angle(Timeline) and Door delay code isn’t work and can you explain why?

Hi, Levani.

A variable exposed through code, like the DoorCloseDelay, won’t be accessible from the variables tab. But you can get or set it through the context menu (right click) and this is also true for most class variables created in code that you’ll find in BP.

If it’s exposed in the variables tab, you can edit its type, and that’s an unwanted behavior.

Right click on the BP graph area and search for 'Set DoorCloseDelay’and you’ll surely find it.

Edit: You can also change it in the Defaults tab of the Blueprint actor instance in the world. Just select the instance in the world and you’ll be able to change its value directly for the instance.

ohhhhh I understand, I have to uncharted Context Sensitive and then it’s accessible thank you :slight_smile:
but still I can’t understand what is doing Open_Angle Timeline component, which is connected Set Play Rate because without it Blueprint is not compiled? can you tell me something about it?

Hi guys,

Where do you see the node called “Set Play Rate”? I can’t seem to find it in my BP.

Oh you just need to uncheck “Context Sensitive” and then you see many more options.

Privacy & Terms