Forum rules - please read before posting.

How to carry a torch

There is a flaming torch in my game which the player can take by clicking on its hotspot. I want it to appear in the game view just in front and to the right of the camera, as though it is being carried. I guess it would need to be a child of the first person player prefab. I'm using Unity 2018.3.5 and AC 1.66.8. I thought maybe the torch could be teleported to the right position, but can't work out how to make the player the parent so that the torch would stay in place when the player moves around. Can anyone help?

Comments

  • I guess it would need to be a child of the first person player prefab

    You'd make it a child of the First Person Camera, if you want it to remain in the same place on-screen regardless of the camera rotation.

  • I tried to do this using Object-Set Parent but get the following message:
    Setting the parent of a transform which resides in a Prefab Asset is disabled to prevent data corruption (GameObject: 'FakeSword').
    Can I overcome this in some way?

  • You're trying to update the prefab, not the scene instance of it.

    Drop the prefab into the scene, set the parent to the child in the scene instance. The child will update with a Constant ID component / value. Apply this change to the prefab and remove from the scene.

  • I'm sorry Chris, I don't fully understand. I've dropped the player prefab into the scene and made the torch a child of the first person camera but when I save and then remove the prefab the torch disappears along with the player prefab

  • Sorry, I wasn't clear.

    I mean that you have to use the Object: Set parent Action to parent the torch to the scene instance of the prefab - not parent the torch manually.

    Drop the prefab into the scene, then create a child object on it that will act as the place to both parent the torch to, and set its position. Attach a Constant ID component to it, and check Retain in prefab?.

    Back in your ActionList, use Object: Set parent and Object: Teleport Actions to position the torch to this new child object. Apply changes made to the scene instance back to the prefab, and remove from the scene.

    The alternative, simpler method is just to leave the Player object in the scene file itself. He doesn't necessarily need to be spawned in via the Settings Manager.

  • Thank you Chris. You are truly a man of infinite wisdom and patience.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.