WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-26-2010, 10:50 PM
turgutm turgutm is offline
Member
 
Join Date: Sep 2010
Posts: 15
How to create circle like collision area

Hi,

I need to create collision area like circle. And I need to get notified when object is inside and when is outside of that area.

Any suggestions?
Reply With Quote
  #2  
Old 01-02-2011, 01:49 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
You can add a function that's called every frame that checks the distance between the object and the center of the circle. Depending on the distance value you'll know whether the object is inside or outside of the circle:
Code:
import viz
import vizact
import vizmat

viz.go()

CIRCLE_CENTER = [0,0,5]
CIRCLE_RADIUS = 2

court = viz.addChild('court.ive')
avatar = viz.addAvatar('vcc_male.cfg')

text = viz.addText('',parent=viz.SCREEN)
text.setPosition(0.3,0.8)
text.color(viz.RED)

walk = vizact.walkTo([0,0,10])
avatar.addAction(walk)

def collisionCheck():
	distance = vizmat.Distance(CIRCLE_CENTER,avatar.getPosition())
	if distance > CIRCLE_RADIUS:
		text.message('Outside circle')
	else:
		text.message('Inside circle')
	
vizact.ontimer(0,collisionCheck)
Reply With Quote
  #3  
Old 01-04-2011, 11:19 PM
turgutm turgutm is offline
Member
 
Join Date: Sep 2010
Posts: 15
Hi, Jeff...
Thanks for reply...

It solved my problem.
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
Collision Exception jassel41 Vizard 2 11-09-2010 05:08 PM
Collision and avatar animation shahramy Vizard 2 10-26-2010 11:47 PM
Collision detection with specific models just alex Vizard 1 02-06-2009 11:02 AM
Collision with child nodes rubberpimple Vizard 4 09-17-2008 04:27 PM
Setting up a 'reaction area' Karthi Vizard 4 01-29-2004 04:39 PM


All times are GMT -7. The time now is 09:35 AM.


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