View Single Post
  #1  
Old 08-24-2009, 07:05 PM
tsmurphy tsmurphy is offline
Member
 
Join Date: Aug 2009
Posts: 4
.addAction in loops

I am trying to do something relatively simple: moving an object at a variable speed. I'm doing this by chopping up the line the object is moving along into intervals, and having each interval (e.g. 1/10th of the entire movement) have a different speed of movement, such that it slows down or speeds up as it moves. This is what I have:

Code:
	
intervals = 10

for index in range(1, intervals): 
    destination = (startPosition-endPosition) * (index/intervals) + endPosition
    speed = destination**2
    movePath = vizact.goto([0, destination, 0], speed)
    cover.addAction(movePath)
    cover.addAction(vizact.spin(0,1,0,90,1))
Here's what should happen. The destination of the particular movement interval is calculated. Then speed is set at the square route of the destination (thus the speed will vary). Then the object ("cover", in this case) queues the action to move down that particular interval at the given speed. It should then spin 90 degrees. And so on for the next interval of the line.

Here's what does happen: It uses the last entry of the loop to determine the speed, moves directly to the final destination, and then spins for 10 seconds after all of the movement is complete (rather than alternating movement and spinning for 1 second). Does anyone know what I can do to fix this, or how I could even start?

Last edited by tsmurphy; 08-24-2009 at 07:07 PM. Reason: to correct something obviously
Reply With Quote