WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   custom avatar random walk (https://forum.worldviz.com/showthread.php?t=1010)

krimble 02-28-2007 04:06 AM

custom avatar random walk
 
I'm coding a scene where I have an animation of a spiderwalkcycle. It's moving up, down, left and right very well.
But that's not what I want.
What I want to do is a spider that is walking to random points. Those points have to be around a certain centerpoint because I have to be able to move that centerpoint.

I know it's a rather advanced question but I don't get it to work.
Does anyone has an idea how I have to code this?

Thank you

farshizzo 02-28-2007 12:16 PM

I've attached a script that generates a set of random points around a center point within a certain radius. You can use the GenerateRandomPoint(x,y,radius) function in your script. Just pass it the center point and radius and it will return a 2D point within the circle. Hope this helps.
Code:

import viz
import math
viz.go()

def GenerateRandomPoint(x,y,radius):
        r = vizmat.GetRandom(0,radius)
        a = vizmat.GetRandom(0,2*math.pi)
        return math.sin(a)*r + x , math.cos(a)*r + y
       
viz.startlayer(viz.POINTS)
for x in range(1000):
        x,y = GenerateRandomPoint(0,1.8,1)
        viz.vertex(x,y,5)
viz.endlayer()


krimble 03-20-2007 03:23 AM

A thanks for you reaction.

Sorry for my late reaction, I'm working on differend things know, but the spiders HAVE to work some day, so thanks for you reply.


All times are GMT -7. The time now is 04:15 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC