Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How Do I Fix My Flawed Unit Movement?

Asked by
Legojoker 345 Moderation Voter
9 years ago

My game has several units that walk through the world at a time, each running their own movement script. All units are moved by this function called repeatedly, calling rate determined by the speed of the unit as the unit will move to a target destination incrementally:

function Move(x,cframe)
    x:SetPrimaryPartCFrame(cframe)
end

The move script functions correctly, and units are able to navigate the map the way I wanted them to. The problem is that with multiple units on the map that a person moves at once, I came across a few bugs. The first one was that the units stacked on top of each other, so I made each unit not be able to "travel" on top of any other unit in the game, since everything else is stationary, and the ray casting I use to find the cframe to position the unit will move it so that it ignores player characters. This next problem I still haven't solved. Since each unit is a different shape and size and rotates to face the point it will be moving towards immediately, units can get stuck "inside" each other. When the angle changes so abruptly, center points of certain units tend to become "encased" in another unit's model, and this can make it VERY annoying and tedious to break them out of each other. Since these units need to group up and move towards the same point, this unit problem occurs very often. I'm wondering if there is a way my units can avoid these awkward collisions. Below you can find a few snap shots of these units incorrectly getting stuck inside each other.

Starting to move them: http://prntscr.com/4av9jg

Them becoming stuck: http://prntscr.com/4av9p8

Me struggling to re-separate them: http://prntscr.com/4avak6

Thank you in advance to anyone who attempts to help me solve this problem. I know it is difficult but I'm hoping someone has a magic method or some sort of strategy to get around this problem :D.

0
A thoroughly written question. With a few pictures. HexC3D 830 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Would a BodyGyro be out of the question to handle rotation?

0
Since cframing requires all bricks to be anchored, yes. Legojoker 345 — 9y
Ad

Answer this question