HoPi`
Joined: 21 Apr 2007 Posts: 11
Digg It |
Posted: 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
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 ), 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
|
|
|