WorldViz User Forum Start_position on animation path
 Register FAQ Search Today's Posts Mark Forums Read

#1
08-20-2009, 08:11 AM
 ptjt255 Member Join Date: Oct 2008 Posts: 24
Start_position on animation path

Hi,

Currently, I have the start position set at [2.0, 1.0, 0.0], but what I really want is for the start position to be wherever the avatar happens to be on the animation path, any help would be really appreciated.

Code:
```# Creates and animation path for the avatar

points = [[2.0,1.5,0.0],[2.0,1.0,0],[2.0,0.0,0]]

for move in range(len(points)):
global move
cp.translate(points[move])
print move

path.loop(viz.SWING)
path.constantspeed(viz.ON,0.5)

# Link the avatar to the joystick and track position and elapsed time
# Defines collision parameters and avatar action on collision

import time

# Variables
result = 0
tinc = 1/100
# from avatar to target the distance is 3.5m
joyscale_x = 1.40 # scale max x joystick velocity to 1.125 m/s maximum (roughly the time it takes to cross a single lane of a road) - 4 seconds to cross 4.5 meters which is 1.5 seconds per meter
joyscale_y = -1.40 # scale max y joystick velocity to 1.125 m/s maximum (roughly the time it takes to cross a single lane of a road)
start_position = [2.0, 1.0,0]

def position_loop():
global start_position, result, x_prev, y_prev, x_velocity, y_velocity, ctime, ij, cframe, y_pos, x_pos, x, y, joy_position, i, select, p, ctime, pos_inc, start_position,elapsed_time,tinc
x_velocity = 0.0
y_velocity = 0.0
x_prev = start_position[0]
y_prev = start_position[1]
#print 'y previous:', y_prev, 'x previous', x_prev
Start_tick = time.time()
cframe = 0

def mytimer(tinc):
global result, x_prev, y_prev, ctime, ij, cframe, y_pos, x_pos, x, y, joy_position, i, select, p, ctime, x_velocity, y_velocity, elapsed_time
# Set up joystick as velocity control
ctime = time.time() - Start_tick
cframe = cframe+1
x = x_prev + x_velocity/60; y = y_prev + y_velocity/60
avatar.setPosition(x,y)
joy_position = joystick.getPosition()
x_prev = x; y_prev = y;
x_velocity = joyscale_x*joy_position[0]; y_velocity = joyscale_y*joy_position[1]
elapsed_time = time.time() - Start_tick```
#2
08-24-2009, 11:40 AM
 Jeff WorldViz Team Member Join Date: Aug 2008 Posts: 2,471
How many different starting points are there? If there are just a few you could create several different paths using the same points. The points would just be in a different order. Then you could link the avatar to the path with matching starting point and play that one.

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Getting Vizard Help with AI Announcements Vizard Precision Position Tracker (PPT) Plug-in development

 Similar Threads Thread Thread Starter Forum Replies Last Post Enlil Vizard 3 11-24-2008 04:23 PM whj Vizard 8 11-17-2008 07:41 PM whj Vizard 10 10-06-2008 04:38 PM djdesmangles Vizard 2 06-11-2007 03:37 PM djdesmangles Vizard 0 06-06-2007 11:03 AM

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