How do I freeze the position of an object in relation to another object when it comes within range and draw a line between them?

I want to make it so that two objects freeze position in relation to each other with a line between them when they get in range of one another (or in other words, bond to each other), but still be able to move apart if it gets bumped by another object. I also want there to be able to be more bonds, but only if a variable ( hasBonds ) is less than another variable ( maxBondNum ) for each object. And for each bond, I want hasBonds to increase by one, then decrease by one if the object leaves the radius. And when hasBonds is equal to maxBondNum, I want it to ignore all other objects as far as bonds are concerned. I have no real code, as I have no clue what I could do.

Hello. This post is suceptible to be deleted… You are asking a lot of different things in 1 post… you give 0 information… its like:" Please make my job for me and i will use it in my project"… I will close the post due is not helping for community. Make a single post for a single problem. You can post multiple times, no problem with that.

I answer you some of the questions…

freeze the position of an object in relation to another object: Depends on how you move you objects,… rigidbody? cinematic? translate? Navmeshagent…

when it comes within range: Use Vecotr3.Distance or use trigger colliders

draw a line between them: Use a LineRenderer component.

Post closed.

Good luck.

Bye!