Adding a camera to actor in Unreal Editor

I have a simulation in which I can move actors placed in the Unreal Editor as well as Simulink using Simulink. I have tried adding a camera to this simulation by going through the walkthrough available on the site: https://www.mathworks.com/help/aeroblks/place-cameras-on-actors-in-the-unreal-editor.html. I have not managed to accomplish this. The crash I am getting is presented in the included image. Adding an actor using Unreal Editor is important to me as I want to be able to customise the camera further than the Simulation 3D Camera allows.
I have tried adding a camera by using a Simulation 3D Camera Get block and a Sim3dSceneCap actor. My actors are presented in the following image.
I also think that the section: Place Camera on Vehicle in Custom Project in the walkthrough is inconsistent with regards to whether it uses: Sim3DCamera or Sim3dSceneCap. I, however, do not exclude the possibility that I do not understand something.
Could you explain how to interface in Simulink to a camera added in the editor?

Answers (2)

Nishan Nekoo
Nishan Nekoo on 26 Nov 2024
Edited: Nishan Nekoo on 2 Dec 2024
Thank you for pointing out the inconsistencies in that documentation page around the Sim3DCamera and Sim3dSceneCap - we'll look into addressing this in a future release. In the meantime, please refer to this documentation page for a similar workflow: https://www.mathworks.com/help/vdynblks/ug/place-cameras-on-actors-in-the-unreal-editor.html
The crash seems to indicate that an actor that doesn't exist is being read or written to.
Nishan

8 Comments

Thank you for the answer. By following the included tutorial I am able to spawn a camera. The Camera Get camera however seems to be stuck at the world origin (0,0,0) and is not getting attached to the Sim3dSceneCap. In Unreal editor the camera is getting attached and moved corretly.
Hi Kamarsto,
I edited my comment above since I don't think the tag names are an issue. Where are you seeing the Camera Get camera stuck at the world origin? Please ensure that the Simulation 3D Camera Get has the tag "1" as decsribed in the example and the Sim3dSceneCap has the tag "IdealCamera1" as described in the example as well. This will ensure that the Simulation 3D Camera Get output as viewed through a Video Viewer, is attached to and moves with the vehicle.
Nishan
I saw camera at the scene origin in the Video Viewer block. I, however, didn't set the tag of Sim3dSceneCap to "IdealCamera1".
When setting these tags to respectively "1" in the block and "IdealCamera1" to a Sim3dSceneCap object the simulation crashes with the included error. I have included my setup in the attached pictures.
Hi Kamarsto,
Thank you for confirming this and providing the crash log. I apologize that you have run into this crash!
This seems like unexpected behavior that I cannot seem to replicate in R2024b Update 2 - can you please clarify what version of MATLAB and Unreal Editor you are using?
I don't believe this will resolve the issue but just to make sure - please uncheck the "Specify Offset" box in the Simulation 3D Camera Get dialog.
Nishan
I am now using Matlaba R2024b and Unreal Enginge 5.3.2
I think i have found a way to replicate the crash. It occurs when I change the Parent Class in the level blueprint to the Sim3dLevelScriptActor from LevelScriptActor.
I am able to get the camera attached to a static object by following the walkthrough.
My goal is to attach a camera to a moving actor which, I deduce cannot be achieved, using methods from the walkthroughs, without changing the Parent Class.
Just to clarify, the crash occurs when the Parent Class is set to Sim3dLevelScriptActor? If you simply change the Parent Class back to the LevelScriptActor, no crash occurs?
You should be able to achieve your goal of attaching a camera to a moving actor even with just the LevelScriptActor and I have just verified this myself. Have you tried doing this? Are you running into any issues?
Nishan
Olgierd
Olgierd on 4 Dec 2024
Edited: Olgierd on 4 Dec 2024
Yes, that is correct.
I have just managed to attach a camera to a Sim3dStaticMeshActor and move it using a Simulation 3D Actor Transform Set block. In the future I will probably attempt to do it using methods in this walkthrough: https://www.mathworks.com/help/releases/R2024b/vdynblks/ug/get-started-communicating-with-the-unreal-engine-visualization-environment.html . I have already went through it succesfully, but without the camera (my troubles started when I wanted to add camera to the simulation I got as a result of completion of the walkthrough).
I have an issue now that after doing any changes in Unreal I have to reopen it via Simulink to get the Simulink past the initialisation stage. Before pressing run in both applications was sufficient.
Edit: I have to do this after each simulation, no matter whether there are any changes
That sounds like unexpected behavior and I apologize for the inconvenience! I'd recommend you reach out to our Tech Support team who can work directly with you to resolve your specific issue.
It would be good to get access to your project so that we can understand the issue better and ensure that your interface has been set up correctly.
Nishan

Sign in to comment.

If anyone else is running into this, it appears to be a timing issue that needs to be resolved.
For now, as a workaround to avoid the crash, ensure the camera or any actor that the camera is attached to ("BP_MarsLander" in this screenshot), is parented to the "PlayerStart" actor - this will ensure that the timing of actor creation etc is correct and avoids a crash.

Products

Release

R2024b

Asked:

on 23 Nov 2024

Answered:

on 15 Jul 2025

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!