Collision checking?

Talk about making games.

Collision checking?

Postby Guardian69 » Tue Jul 05, 2011 11:57 am

Hi guys

I have two actors that require collision. One is the player actor and the other is a scenery actor.

I want to be able to check if an actor can move into a space before they do. Ideally I would use a function to check the proposed 2d vector and return a Boolean value that identified if it was occupied.

Does such a thing exist? If not how would I set one up?

Cheers,
Guardian
User avatar
Guardian69
 
Posts: 17
Joined: Thu May 26, 2011 9:05 pm
Location: United Kingdom
Score: 0 Give a positive score

Re: Collision checking?

Postby Imperialjester » Tue Jul 05, 2011 3:44 pm

they have a function called collisionfree that does just that.
User avatar
Imperialjester
 
Posts: 185
Joined: Wed Dec 08, 2010 5:39 pm
Score: 10 Give a positive score

Re: Collision checking?

Postby Guardian69 » Tue Jul 05, 2011 4:01 pm

Ah awesome! Thank you!

"CollisionFree: Check if position (x, y) is collision free for ActorName. Return 1 if not collide, 0 otherwise."

So if I am using the following script in my players draw event, how would I get the player actors next x and y?

"yvelocity = yvelocity + 1;
xvelocity *= .95;"
User avatar
Guardian69
 
Posts: 17
Joined: Thu May 26, 2011 9:05 pm
Location: United Kingdom
Score: 0 Give a positive score

Re: Collision checking?

Postby Imperialjester » Tue Jul 05, 2011 5:33 pm

i dont know im not an expert on it. ask Hblade hes a good coder.
User avatar
Imperialjester
 
Posts: 185
Joined: Wed Dec 08, 2010 5:39 pm
Score: 10 Give a positive score

Re: Collision checking?

Postby skydereign » Tue Jul 05, 2011 8:08 pm

The actor's next position will be (x+xvelocity, y+yvelocity) assuming you have already changed xvelocity and yvelocity (after this part).
Code: Select all
yvelocity = yvelocity + 1;
xvelocity *= .95

If not, you position will be (x+xvelocity*0.95, y+yvelocity+1).
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest