I don’t know if this is the right forum, but I don’t know where else. Is it possible to set an object to change material as soon as the character (PhysicsBallBP) comes into contact with it? If you don’t get it, think of the ball as King Midas, where as soon as he touches something, it turns to gold
Yes, it is possible but you have to setup it using blueprints. This is how I would do it:
- Create a blueprint interface ChangeColorOnContactBPI and add function SetIsInContact(bool IsInContact) - you will implement this interface on any objects that receives color changes
- Create a blueprint for each object that receives contact collision and implement ChangeColorOnContactBPI.
a) Create either more variants of material for the object (gold, normal) or use material parameters to change the look (IsInContact parameter, 0 gives default look, 1 gives gold look)
b) Add static mesh/any other components to the blueprint
c) On BeginPlay, create dynamic material instance (if you opt for material parameter)
d) In SetIsInContact(bool) either set the correct material parameter (0 or 1) or swap the material on the static mesh. If you use material parameter, you can create a timeline, let’s say 0.2 seconds long and drive the value from 0 to 1 or 1 to 0 depending on enter or exit contact
e) Make sure you add collision component; either on static mesh or add a new component that server as a trigger. Enable generate overlapping events - On the character, enable generate overlapping event and on BeginOverlap and EndOverlap, call SetIsInContact to the actor in contact. This call will get ignored on actors that do not implement this interface, otherwise the function gets called. You might need to tweak some collision presets so the overlap between pawn and the object interface is not ignored. If you want bigger radius for in/out contact, create a new capsule/sphere/box component, set it to overlap and use its begin/end overlap events instead!
- Adding new objects that turn gold just means properly repeating step 2), other things should be automatic
Hope this helps