x


momentum canceling

Hello, I'm making a 2d platform game and my player's momentum is having problems. When I jump on a moving platform going up/right/left my character shoots in the direction the platform was going in much farther than a regular jump and he does not start falling down for a long time. Any help would be very appreciated.

Thanks, zAk

more ▼

asked Jan 04 '12 at 07:15 PM

zAk1 gravatar image

zAk1
1 1 2 2

I would need a snippet of the walk and jump code to be of any use. Im going to assume your using a physics walker script?

Jan 04 '12 at 10:50 PM chemicalvamp

I actually don't know what a physics walker script is... but I'm using the platform controller script from the 2DGameplayTutorialProject in the walkthrough. I found that applying a rigidbody component to the character and setting both drags to 30 helps, but It's only a temporary fix. Is there anything that can fix this for good?

`class PlatformerControllerJumping { // Can the character jump? var enabled = true;

function onJump () { velocity = 0; angularVelocity = 0; }

    // How high do we jump when pressing jump and letting go immediately
var height = 1.0;
// We add extraHeight units (meters) on top when holding the button down longer while jumping
var extraHeight = 4.1;

// This prevents inordinarily too quick jumping
// The next line, @System.NonSerialized , tells Unity to not serialize the variable or show it in the inspector view.  Very handy for organization!
@System.NonSerialized
var repeatTime = 0.05;

@System.NonSerialized
var timeout = 0.15;

// Are we jumping? (Initiated with jump button and not grounded yet)
@System.NonSerialized
var jumping = false;

@System.NonSerialized
var reachedApex = false;

// Last time the jump button was clicked down
@System.NonSerialized
var lastButtonTime = -10.0;

// Last time we performed a jump
@System.NonSerialized
var lastTime = -1.0;

// the height we jumped from (Used to determine for how long to apply extra jump power after jumping.)
@System.NonSerialized
var lastStartHeight = 0.0;

}

var jump : PlatformerControllerJumping;

private var controller : CharacterController;

// Moving platform support. private var activePlatform : Transform; private var activeLocalPlatformPoint : Vector3; private var activeGlobalPlatformPoint : Vector3; private var lastPlatformVelocity : Vector3;

// This is used to keep track of special effects in UpdateEffects (); private var areEmittersOn = false;

function Awake () { movement.direction = transform.TransformDirection (Vector3.forward); controller = GetComponent (CharacterController); Spawn (); } `

Jan 05 '12 at 01:57 AM zAk1
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

I actually don't know what a physics walker script is... but I'm using the platform controller script from the 2DGameplayTutorialProject in the walkthrough. I found that applying a rigidbody component to the character and setting both drags to 30 helps, but It's only a temporary fix. Is there anything that can fix this for good?

`class PlatformerControllerJumping { // Can the character jump? var enabled = true;

function onJump () { velocity = 0; angularVelocity = 0; }

    // How high do we jump when pressing jump and letting go immediately
var height = 1.0;
// We add extraHeight units (meters) on top when holding the button down longer while jumping
var extraHeight = 4.1;

// This prevents inordinarily too quick jumping
// The next line, @System.NonSerialized , tells Unity to not serialize the variable or show it in the inspector view.  Very handy for organization!
@System.NonSerialized
var repeatTime = 0.05;

@System.NonSerialized
var timeout = 0.15;

// Are we jumping? (Initiated with jump button and not grounded yet)
@System.NonSerialized
var jumping = false;

@System.NonSerialized
var reachedApex = false;

// Last time the jump button was clicked down
@System.NonSerialized
var lastButtonTime = -10.0;

// Last time we performed a jump
@System.NonSerialized
var lastTime = -1.0;

// the height we jumped from (Used to determine for how long to apply extra jump power after jumping.)
@System.NonSerialized
var lastStartHeight = 0.0;

}

var jump : PlatformerControllerJumping;

private var controller : CharacterController;

// Moving platform support. private var activePlatform : Transform; private var activeLocalPlatformPoint : Vector3; private var activeGlobalPlatformPoint : Vector3; private var lastPlatformVelocity : Vector3;

// This is used to keep track of special effects in UpdateEffects (); private var areEmittersOn = false;

function Awake () { movement.direction = transform.TransformDirection (Vector3.forward); controller = GetComponent (CharacterController); Spawn (); } `

more ▼

answered Jan 05 '12 at 01:59 AM

zAk1 gravatar image

zAk1
1 1 2 2

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2057
x2

asked: Jan 04 '12 at 07:15 PM

Seen: 323 times

Last Updated: Jan 05 '12 at 01:59 AM