1

I have two objects, both with different textures and I want to make them the same at a certain point of time. The current code I am looking at is the following:

weaponObject.renderer.material.mainTexture = selectedWeapon.renderer.material.mainTexture;

Unfortunately this does not seem to work. The "weaponObject" texture seems to remain the same but simply moves further backwards in terms of the z axis. Any tips? Both Objects are type GameObject.

1 Answer 1

2

You need to make sure that the textures fit both GameObjects. Pretty much you can't attach the texture of an m4 to an m16, the texture won't align correctly.

You also need to make sure that both objects use the same type of material. Remember a material affects how it will look, so even the same texture on different materials will look different.

Example, same texture with different materials:

enter image description here

If the two objects are identical, which they should be if you want consistent results, then just swap the materials:

weaponObject.renderer.material = NewMaterial;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.