whatdotcolour collision
Author |
Message |
shoobyman
|
Posted: Sat Nov 25, 2006 3:07 pm Post subject: whatdotcolour collision |
|
|
code: | if bdgotox (i) > builderx (i) and whatdotcolour (builderx (i) + 10, buildery (i)) = 27 then
builderx (i) += 1
elsif bdgotox (i) < builderx (i) and whatdotcolour (builderx (i) - 10, buildery (i)) = 27 then
builderx (i) -= 1
end if
if bdgotoy (i) > buildery (i) and whatdotcolour (builderx (i), buildery (i) + 10) = 27 then
buildery (i) += 1
elsif bdgotoy (i) < buildery (i) and whatdotcolour (builderx (i), buildery (i) - 10) = 27 then
buildery (i) -= 1
end if
|
I am making an RTS and i am trying to make collision for the builder unit. If he moves into an area that is not colour 27 (grey), he should not be able to move. but the problem is that when he moves diagonally he can move into non grey parts a little. This really messes things up because he can move ontop of other builders and then you lose control of him . Anyone know how to fix this? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Windsurfer
|
Posted: Sat Nov 25, 2006 6:42 pm Post subject: (No subject) |
|
|
I find that the easiest thing to do for full-stop collision is to make a "following" variable that you use for when it collides. Basically, you set the variable to the location of the object (or builder) then get the builder (or object) to move as it would normally. If it is overlapping grey, simply reposition the object to the "following" variable, as it will be at it's last position. Simple! |
|
|
|
|
|
|
|