Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

Javascript code with Unity3D

Mon Mar 22, 2010 9:55 pm

at the moment I'm working on writing a code for a interactive project. This project is made out of a 3dmodel, that I made in 3dsmax. I want to animate this model, and make it respond to an actual person by motion detectors and a camera that works together with a javascript code.

I'm trying to make this animated model walk to different coordinates. When doing so I have two different choices, either my object 'slides' to a location, or the object does a 'walkcycle' which remains in place. (So the background moves.) What I want, ideally, is a sliding walkcycle. This has to have a place where it has to stop, so it doesn't move out of the picture. (I hope this still makes some sense.)

I am now working in Unity3d. When the webcam receives a value above '200', the walking cycle begins. With the value is below 200 my object doesn't move.

My problem now is, that when the webcam gives these values above 200, the values don't go down anymore. My object gets stuck in it's animation and keeps repeating it.

My question is if maybe you can help me out with my code. This is the code:



Code:
public var RemoteIP : String = "127.0.0.1"; 
public var SendToPort 
: int = 9000; 
public var ListenerPort 
: int = 8000; 
public var Controller
: Transform; 
private var handler 
: Osc; 
private var sigX 
: int = 160; 
private var sigY 
: int = 120; 

public function Start 
() 
{ 
var udp 
: UDPPacketIO = GetComponent("UDPPacketIO"); 
udp
.init(RemoteIP, SendToPort, ListenerPort); 
handler 
= GetComponent("Osc"); 
handler
.init(udp); 
handler
.SetAddressHandler("/X-as",X); 
handler
.SetAddressHandler("/Y-as",Y); 
} 

Debug
.Log("Start"); 

function Update 
() 
{ 
var go 
= GameObject.Find("model"); 
go
.animation.wrapMode = WrapMode.Once; 
go
.animation["idle"].wrapMode = WrapMode.Loop; 

go
.animation.Play("idle"); 

if(sigX > 200) { 
go
.animation.Play("walk"); 
} 
} 

public function X 
(oscMessage : OscMessage) : void 
{ 
Debug
.Log(Osc.OscMessageToString(oscMessage)); 
sigX 
= (oscMessage.Values[0]); 
} 

public function Y 
(oscMessage : OscMessage) : void 
{ 
Debug
.Log(Osc.OscMessageToString(oscMessage)); 
sigY 
= (oscMessage.Values[0]); 
} 
 


Anyways, sorry for the long message and I really hope you can help me out. Thank you so much in advance for reading this!



Post a reply
  Related Posts  to : Javascript code with Unity3D
 Redirect to a New Page javascript code     -  
 First Visit Pop Up Window javascript code     -  
 Preloading Images javascript code     -  
 Typing Status Bar Text javascript code     -  
 Back to previous page javascript code     -  
 Status Bar Link Description javascript code     -  
 Reload a Window With a Button javascript code     -  
 Javascript Code For Moving Images On Click Of A Button     -  
 Freeman chain code algorithm code     -  
 i want code for connecting mobile and pc can u send me code     -