change texture of my enemy when my character destroys a seed

hello. I would like to know if there is a way that when my character destroys a seed my enemy automatically changes texture

my character

my seed

my enemy

What exactly is the problem? What’s happening? Is the cast to “Movimientos” succeding or failling?

I’m basically doing a pacman project. the problem is that when i destroy the special seed to kill the ghosts, i want the ghosts to change from their zombie blue texture automatically

You can use interfaces for this.

You start with a material with a texture parameter:

Then create an interface with a function called, for example, ChangeTexture:

In you ghost, you create a dynamic material in the constructor:

and add the interface to the ghost, COMPILE, and then implement the event ChangeTexture:

When you eat the pebble, you call all actors that implement that interface and send a message to change their textures:

PS: in this case, there is no problem in using “Get All Actors …” since it’s a sporadic use.

1 Like

thank you very much, i will try

I have a freeze tag mode in my game. In multiplayer, you have to multicast it so that all the clients see the updated skin.

Use an event dispatcher. Have all the ghosts listening in for the event to be dispatched. The Seed dispatches the event. All the listening Ghosts have their ChangeMaterial event triggered. They all change material. After a delay, they change back. Unless they are eaten first.

1 Like

thanks, i’ll try

hello. I came back hehe.
I ask you, what type of variable did you use here?

Material Instance Dynamic.

When you don’t know the return type, you can always place the mouse over the output pin and get the type:

or RMB and Promote to Variable, to automatically create the a variable of the right type:

1 Like

thank you

hello. I have another problem. I can’t locate the “interfaces” tab and I can’t find to generate the event

I only did this in this part

Go to the Class Settings:

1 Like

Hello. I tried to make the knots and there I was able to achieve them but in the end it did not give me the result that I expected

here create the interface

in the ghost

and here I don’t know where to put this

The last nodes you put them either in the player or in the seed, i.e., wherever you have the collision event. Instead of the event “1”, you use the collision event.

1 Like

hello. still no effect. I think the problem is in the material0 variable, I’m not sure. I send you the seed

Did you set the Parameter Name in “Set Texture Parameter Value”? Make sure to pu the sama parameter name as in the material, in my case “GhostTexture”.

1 Like

hello. Excuse my ignorance :grin: but where do I create the texture parameters?

Right click on the Texture node and select “Texture parameter” or something like that.

1 Like

hello. good day . Still nothing. can i send you the project?

Material 0??? It should be the same “Material” variable that you have in the constructor of the ghost, the one right after “Create Dynamic Material Instance”.

1 Like