WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 06-15-2018, 12:01 PM
hannahapz hannahapz is offline
Member
 
Join Date: Apr 2018
Posts: 14
Stop avatar from walking to its destination

I'm fairly new to Python and Vizard, so the answer to this may be strikingly obvious to some.

I'm trying to stop my pedestrian avatar from walking to a final location as soon as I enter within the bounds of its proximity sensor.

My current code is as follows You can assume I've done all necessary module imports:

Code:
def set_avatar_proximity_sensor():
	global manager, sensor
	manager = vizproximity.Manager()
	manager.setDebug(viz.ON)

	target = vizproximity.Target(Me)
	manager.addTarget(target)
	
	sensor = vizproximity.addBoundingSphereSensor(pedestrian,scale=2)
	manager.addSensor(sensor)
	
	vizact.onkeydown('d',manager.setDebug,viz.TOGGLE) 
	
def pedestrian_actions():
	runAction = vizact.walkTo( [-12, 0, 3] )
	pedestrian.addAction (runAction) 

def enter_proximity(e):
        runAction = vizact.walkTo( [-12, 0, 3] )
	pedestrian.addAction (runAction)

set_avatar_proximity_sensor()
vizact.ontimer(0, pedestrian_actions)
manager.onEnter(sensor, enter_proximity)
So, right now, the enter_proximity function is obeyed only after the pedestrian_action function has ended. How do I interrupt the pedestrian_action function however?
Reply With Quote
  #2  
Old 06-15-2018, 06:27 PM
hannahapz hannahapz is offline
Member
 
Join Date: Apr 2018
Posts: 14
I've been able to stop the animation of the avatar's body using an if statement, but otherwise have not been able to stop the avatar's trajectory to a destination.
Reply With Quote
  #3  
Old 06-15-2018, 09:38 PM
hannahapz hannahapz is offline
Member
 
Join Date: Apr 2018
Posts: 14
Solved

I solved the issue with a simple if-elif statement

Code:
def pedestrian_actions(): 
	ped_position = pedestrian.getPosition()
	car_position = car.getPosition()
	distance = vizmat.Distance(ped_position, car_position)
	runAction = vizact.walkTo( [-12, 0, 3] )
	print(distance)
	
	if distance > 4:
		pedestrian.addAction (runAction) 
	elif distance < 2:
		pedestrian.clearActions()
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
avatar walking backward sbilleter Vizard 1 09-18-2015 12:26 PM
Walking Animation of Avatar pradeep Vizard 1 07-03-2014 04:35 AM
How to simulate avatar walking along a slanted surface Zhi Vizard 3 11-21-2013 05:27 PM
walking of avatar via patriot Veronika Vizard 6 10-07-2011 01:33 AM
avatar walking over a sequence of points IGoudt Vizard 1 10-16-2009 12:22 PM


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


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