- Home /
is there any way to have a sprite link to another sprite.
I have a scene with a sphere (player) and 2 other spheres. I would like for once the player touches the other spheres they link with some form of gravity, or just stick together. I've tried various forms of parenting, gravity, force motion, etc. I haven't found a way to make it work. does anyone have an idea?
Answer by Ohiorenua · Oct 06, 2021 at 12:49 AM
lets say your player is "A" and the other sprite is "B" you could do a collision check and assign the transform.position of "B" to "A", and update it so that "B" is always with "A"
void Update() { otherGameObject.transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z); },lets say your player is "A" and the other sprite is "B". you set the transform.position of "B" to that of "A" when a collision has occurred and always update "B" transform.position in the Update() function.
void Update(){ otherGameObject.transform.position = new Vector3(transform.position.x, transform.position.y, 0); }
hope this helps.
Your answer

Follow this Question
Related Questions
Best performance, best graphics. Looking for tips. 0 Answers
I want to develop an mmo... where do i start? 1 Answer
scroll bar inventory with slot count for equip items 0 Answers
How to add force like a "kick" relative to swipe angle? (Skate game) 1 Answer
So many problems with Text Mesh Pro 0 Answers