Currently I am working on a scene in which I as viewer am surrounded by a lot of walking people (the default avatars).
However, the walkto-command sometimes lets an avatar walk through 'myself', resulting in a jump of the viewpoint (due to the collision detection). In what way is it possible to solve this problem (proposed it
is possible!)? I can mess a little with the coordinates I send the character to, but as I can walk freely through the scene, this cannot be guaranteed.
Another problem is avatars walking through each other. Don't they have any collission detection?
And to ask my last question: is it possible to group avatar objects into an array? Take a look at my code below and you'll understand why
.
See an example piece of code below:
PHP Code:
import viz
import whrandom
# Handles all timer events for the therapist machine
def mytimer(num) :
if (num == 1) :
view_pos = view.get(viz.HEAD_POS);
a1.act(a1.walkto(view_pos[0] + whrandom.randint(-2, 3), 0, view_pos[2] + whrandom.randint(-2, 3)));
a2.act(a2.walkto(view_pos[0] + whrandom.randint(-2, 3), 0, view_pos[2] + whrandom.randint(-2, 3)));
a3.act(a3.walkto(view_pos[0] + whrandom.randint(-2, 3), 0, view_pos[2] + whrandom.randint(-2, 3)));
a4.act(a4.walkto(view_pos[0] + whrandom.randint(-2, 3), 0, view_pos[2] + whrandom.randint(-2, 3)));
a5.act(a5.walkto(view_pos[0] + whrandom.randint(-2, 3), 0, view_pos[2] + whrandom.randint(-2, 3)));
a6.act(a6.walkto(view_pos[0] + whrandom.randint(-2, 3), 0, view_pos[2] + whrandom.randint(-2, 3)));
a7.act(a7.walkto(view_pos[0] + whrandom.randint(-2, 3), 0, view_pos[2] + whrandom.randint(-2, 3)));
a8.act(a8.walkto(view_pos[0] + whrandom.randint(-2, 3), 0, view_pos[2] + whrandom.randint(-2, 3)));
a9.act(a9.walkto(view_pos[0] + whrandom.randint(-2, 3), 0, view_pos[2] + whrandom.randint(-2, 3)));
viz.go(0);
view = viz.get(viz.MAIN_VIEWPOINT);
# Create the room and make it a bit larger
myroom = viz.add('../room/room.wrl');
myroom.scale(10, 3, 10);
# Set background color
viz.clearcolor(0, 0, 0);
# Turn on collision detection
viz.collision(viz.ON);
viz.stepsize(0);
# Test moving avatars
a1 = viz.add('female.cfg'); a1.translate(1, 0, 1);
a2 = viz.add('female.cfg'); a2.translate(1, 0, 1);
a3 = viz.add('female.cfg'); a3.translate(1, 0, 1);
a4 = viz.add('female.cfg'); a4.translate(1, 0, 1);
a5 = viz.add('female.cfg'); a5.translate(1, 0, 1);
a6 = viz.add('male.cfg'); a6.translate(1, 0, 1);
a7 = viz.add('male.cfg'); a7.translate(1, 0, 1);
a8 = viz.add('male.cfg'); a8.translate(1, 0, 1);
a9 = viz.add('male.cfg'); a9.translate(1, 0, 1);
viz.callback(viz.TIMER_EVENT, mytimer);
viz.starttimer(1, 1, viz.FOREVER);