WiiLi Wiki frontpage Include your post in the News Get links Hoteles Quito
WiiLi.org Forum Index WiiLi.org
a new revolution
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

tilted nunchuk & affected axes

 
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Scripts
View previous topic :: View next topic  
Author Message
HoPi`



Joined: 21 Apr 2007
Posts: 11

Digg It
PostPosted: Tue May 15, 2007 1:52 pm    Post subject: tilted nunchuk & affected axes

Hi there,
I tried creating my own MotoGP script because I wasn't quite satisfied with TigerGDs one that only uses key mapping for steering and accelerating.

Mine uses PPJoy and, so far, it works. Steering and accelerating works perfect, after a few minutes of testing and tweaking I was able to do a race without crashes Very Happy

The problem is braking. I want to accelerate like on a "real" motor cycle, with the right hand. TigerGD uses buttons to break, I want to break with the Nunchuk affecting the same axis as the Wiimote. In other words:
- accelerate: Wiimote tilted backwards
- brake: Nunchuk tilted backwards

The nunchuk bothers me because 2 axes (y and z) seem affected when I tilt it (holding it "in a motorcycle way". See TigerGDs video, you'll know what I mean Smile ), i.e. the cycle brakes AND steers left. I don't know what to do about this one... any help is appreciated.

Code:

// Wiimote trim values
// hold wiimote like acceleration handle and then trim to 0
var.xtrim = -20
var.ytrim = -17
var.ztrim = 1
// Nunchuk trim values
var.nxtrim = -3
var.nytrim = -31
var.nztrim = 0

var.accx = wiimote.RawForceX + var.xtrim
var.accy = wiimote.RawForceY + var.ytrim
var.accz = wiimote.RawForceZ + var.ztrim

var.naccx = Wiimote.Nunchuk.RawForceX + var.nxtrim
var.naccy = Wiimote.Nunchuk.RawForceY + var.nytrim
var.naccz = Wiimote.Nunchuk.RawForceZ + var.nztrim

var.accelerate = var.accy // gas
var.brake = var.naccy // brake
if var.accelerate < -2 then
   Wiimote.Rumble = true
   PPJoy.Analog0 = var.accelerate/20
else
   Wiimote.Rumble = false
   PPJoy.Analog0 = 0
   // check if Nunchuk is tilted, then brake
   if var.brake < -20 then
      PPJoy.Analog0 = -(var.brake+20)/50
   endif
endif

PPJoy.Analog1 = (var.accz/15-var.naccz/15)/2 // steering

// Wiimote debug
debug = "Wiimote: "+var.accx + " " + var.accy + " " + var.accz + "; Nunchuk: " + var.naccy + " " + var.naccx + " " + var.naccz
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Scripts All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group