Hi,
So First off how would you recommend:
A) swapping objects in and out for when a player is carrying an object? I will run a walk, idle, talk spritesheet frame animation, but want to swap the object that the player is holding at times. Ie holding a lit candle in a dark room.
Turning off / on the URP light of the candle?
See screenshot for initial gameobject in Player prefab:
https://www.dropbox.com/s/4g9v3ptwz772p30/PlayerObject Swap out.png?dl=0
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
It'll be more efficient to rely on skeletal animation if you plan to carry multiple items.
With frame-by-frame animation, you'd either have to create full-body animation sets for the character carrying each item, or carefully animate the position of a separate "held object" sprite to match with the character's hand for each frame.
For the object's sprite to change based on their held item, you could either use scripting to update its sprite (similar to this thread), or use sub-layers of the character's Animator.
For turning on/off a light in URP, you can either use an Animator sub-layer, or use the Object: Call event Action to disable/enable the 2D Light component.
How can I call this for the player prefab object though? That is where the light is
Attach this and use the Object: Send message Action to run its Show and Hide functions.
attach this to the light or the player root? Thanks!
Either - you assign the light component in its Inspector.
Hi sorry, this isn't currently working, please see screenshots:
https://www.dropbox.com/sh/0bvng8dzpmcxuzv/AABTttA4gtB92xYU3FXfCrufa?dl=0
tried putting the script on the light itself too and that didn't work either
You need to call the script's Show and Hide functions - not Turn On or Turn Off.
Using object call event? I cannot drag the object with the script on into the unity event?
https://www.dropbox.com/s/exfe1od98jn5m98/Object Call Event.png?dl=0
No, with the Object: Send message Action.
There are no Show or Hide functions?
https://www.dropbox.com/s/rzecdga54r7qkgo/NoShowHide.png?dl=0
Choose Custom and type in the name below.
Show
Ok, this is still not working for me. See set up screenshots:
https://www.dropbox.com/sh/f4qs54dxxo0t13x/AAB2e0V9VLrNm9IQkFoyqVhka?dl=0
The GameObject must be enabled. The script affects the component.
Awesome works perfectly!
Hi, would I be able to use this to turn on a particle system too that is a child of the player prefab?
If you attach a ParticleSwitch component to the Particle System, you can use a separate Object: Send message Action to invoke either its TurnOn or Interact function.