Hi. By default my flashlight doesn’t follow my character’s camera (as intended). It has no parent, as seen in the component list. By holding the right mouse click, the camera zooms and the flashlight cone gets parented to the camera (so that it follows the direction the character is looking at). However, I want to unparent the flashlight cone once I release the right mouse click (back to default view).
Here’s a screenshot
As you can see I’m able to parent the flashlight cone to the camera with the attach to component node. I just don’t know how to unparent it. I tried adding another attach to component node below (between orient rotation to movement and camera rotation lag speed set to 15) and plugging nothing in the parent pin since I want it to have no parent once I release the button. But nothing works so far. Any clues?
EDIT: So I’ve managed to do something. I’ve added an attach to component node for the release button and set the parent to mesh (because it’s parented to the mesh by default), but now each time I press the zoom button the flashlight cone gets pushed further and further away from the character.
I dont know if this is a smart way to do, but I always do these via spawning the child objects as their own separate blueprint actor. In your case I would have a placeholder for the usable in the maincharacter, that is not existing in the game. When the usable object (flashlight) is turned on, I spawn an actor to the location/rotation of the placeholder, and when its not needed anymore, I destroy the actor.
If its a third person view game/object in game where you actually see the flashlight all the time, I have the flashlight on belt for the main character for example, and make it invisible at the same time, when the used object is spawned, and visible when the object is put back to its original position. Might sound fishy, but visually it works at least.
I havent been able to juggle between attachments properly either, as I would in 3D software animations with keyframes and blends etc. so I have used this solution instead. BUT! I am not saying this is the best way to go…someone might have better answer.
Basically I’m switching from the normal light to the light parented to the camera when zooming. I also followed your advice and created the flashlight as an actor (which is the right thing to do since my character will have to pick it up).