Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

I cannot change the sprite of a prefab clone

$
0
0
Hi everyone ! I am currently trying to change the sprite from the SpriteRenderer of an instantiated prefab to another after a collision. I have attached a script to the prefab containing this : public Sprite newSprite; void OnTriggerEnter2D(Collider2D col) { GetComponent().sprite = newSprite; } My prefab has a BoxCollider2D and a RigibBody2D, and I am sure that I go through this code thanks to Debug.Log. Furthermore, when I print the sprite before and after on the console, it looks like the sprite has changed. However, in game nothing happens... I think it's because I want to change the sprite of a clone and it's an issue but I'm not sure. I have searched for a lot a answers but nothing helped me. Thanks in advance and have a good day !

Viewing all articles
Browse latest Browse all 508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>