Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   Collisions in Alice - preventing character running into walls (http://www.alice.org/community/showthread.php?t=8403)

4rianna 04-23-2012 08:03 AM

Collisions in Alice - preventing character running into walls
 
After sfunks's collision tutorial I tried using collisions and they worked really well. I can make instances of the alice character/animal objects collide but am having issues with making my scientistWoman collide with the walls of my layout.

I created a 'map' in 3DS max and imported it to Alice.
Once in Alice I saved it as an object and left the first instance of it as there don't seem to be any problems.
Map: (Centre wall), (floor:plane1, ... , plane23), (wall:wall003, ... , wall008)

On creating an event 'When world is running: During: run world.collision [building.wall]'

Where world.collision is
IF scientistWoman is within 1 metre of [objectToHit]
scientistWoman move backward 1 metre duration 0.1 sec style abruptly
ELSE nothing

and [objectToHit] is a parameter, in this case building.wall

Problem: I'm making a FP game and my character just moves through the walls when I want it to collide and NOT walk through the walls. Any ideas would be appreciated, thanks for your time!

Mr Kidnapper 04-23-2012 08:53 AM

I'm not sure what collision method you're using. Mind elaborating?

I'm assuming that this is just a check for if an object is near another and then force them to move backwards. If that's the case then I probably know what's wrong. See, you're trying to make a wall collision act like a sphere collision. What "1 meter away from" does is check if an object is 1 meter away from the object's pivot point in a circular radius. What you should use is "To the left of", "In front of", and use the wall's length, width, and height to calculate the wall's collision as a rectangular prism.

4rianna 04-23-2012 09:27 AM

See, you're trying to make a wall collision act like a sphere collision. What "1 meter away from" does is check if an object is 1 meter away from the object's pivot point in a circular radius. What you should use is "To the left of", "In front of", and use the wall's length, width, and height to calculate the wall's collision as a rectangular prism.

Of course, sorry. It is a check! When I said collision method I meant a method I'd written causing what I think looks like a collision. Apologies for imprecise terminology!

The method was: (parameter is objectToHit)
IF scientistWoman is within 1 metre of [objectToHit]
scientistWoman move backward 1 metre duration 0.1 sec style abruptly
ELSE nothing

Basing on what I understood in your post I now have:
object parameter = objectToHit
local int variable = distanceFromObject
[I]distanceFromObject[/I] set value to [I]scientistWoman[/I] distance in front of [I]objectToHit[/I]
IF [I]scientistWoman[/I] distance in front of [I]objectToHit[/I] <0.1
[I]scientistWoman[/I] move backward 1 meter duration
ELSE nothing

The walls are not just single rectangular walls but if I just go through them one by one, applying that method it looks like it will work well! I used the above on a wall object that is a hexagon and it seems to take the area as a square and calculate distance in front of.. from the edge of the square.

Thank you, I really appreciate your time.

Mr Kidnapper 04-23-2012 05:14 PM

Yes, the width, height, and length that Alice refers to is the width height and length of the bounding box of the subobject, which is why if you want complex collision you need to separate an object into simple primitive objects, maybe even use an invisible, low poly collision "proxy" (That's what my community calls it), in this case made out of Alice spheres and rectangles.

Though to elaborate, this is what I mean: [url]http://alice.org/community/showthread.php?t=7643&postid=44920[/url]

Read the next few posts after it as well as the link inside the post.


All times are GMT -5. The time now is 01:21 AM.

Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.