unity3d - Google Cardboard Magnet Refresh Not Working in Unity -


i need google cardboard magnet. created ball game , want when pull magnet, ball jump. first round, magnet works fine, when restart level (by falling down) magnet doesn't work anymore. used script called magnetsensor.cs (https://github.com/theqwertman/unitycardboardtrigger/blob/develop/magnetsensor.cs). here's ball control script. if can, please me. try me format code when pasting inside of unity forums; don't know how to. that's why code messy:

var rotationspeed = 100; var jumpheight = 8;  var hit01 : audioclip; var hit02 : audioclip; var hit03 : audioclip; var disttoground : float;  function start () { disttoground = collider.bounds.extents.y; }  function update () {     var rotation : float = rotationspeed;     rotation = time.deltatime;     rigidbody.addrelativetorque (vector3.back rotation);     magnetsensor.onmagnetpull += jumponmagnet; }  function isgrounded () : boolean {     return physics.raycast(transform.position, -vector3.up, disttoground + 0.1); }  function jumponmagnet () { rigidbody.velocity.y = jumpheight; }  function oncollisionenter () {     var thehit = random.range(0, 3);     if (thehit == 0) { audio.clip = hit01; }     else if (thehit == 1) { audio.clip = hit02; }     else { audio.clip = hit03; }     audio.pitch = random.range (0.9,1.1);     audio.play(); } 


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -