Reputation: 2117
I'm trying to create simple game where you jump around with ropes hooking to flying islands. I want islands to just float and when hooks himself to this island he begins to pull it to himself, but he is also able to swing on it. After he releases the rope islands slows down and stops (but I guess this is done by the rigidbody drag). Can you tell me how this script could work because I don't have any good idea of doing this.
Upvotes: 0
Views: 727
Reputation: 430
You should disable gravity for the islands' rigidbody, first of all. That way, they will float, but things like inertia will still apply.
If you want your character to pull the islands to himself when grabbing them with a rope, you could use Rigidbody.AddForce(Vector3 vec3)
and pass the vector opposite to the direction the rope is aimed at as a parameter (you should use Vector3.Reflect()
to do that.)
This will get you started, but there are more ways to improve the effect, such as making the islands gradually slow down after pulling them. I'd suggest multiplying the island's velocity by a fraction of 1, in that case, but there are other ways to do it.
Upvotes: 1