Player Collision, Constant Force, Physics Q

I’ve got a player that goes left/right and up/down (wasd), I want the players movement to be constant one speed in the z plane.

I’m using Constant Force Component, but I’m only colliding with Physics/Mesh Colliders.
So my tagged ‘fallout’ box isn’t collidable, neither is my turret or bullets.

I think this is because I’m using Constant Force on the player. Is there a better way to do that?

Scripting foward movement instead of constant force component.

Hiya,

instead of using constant force …you can try character controller on the player and then you can use MOVE() to move the function in a particular direction

thanks, I’m using this right now, with character controller.

// flies foward always, quickly
var speedOfTravel = 10;

function Update() {
// Move the object forward along its z axis 1 unit/second.
transform.Translate(Vector3.forward * Time.smoothDeltaTime);

}

also trying to figure out how to make it faster than 1 unit/second.

player only collides with rigidbodies though… I need to learnmore about collision.

Buddy… why are you using Translate()…try CharacterController.Move();…

you can try this…

function Update()
{
moveDirection=transform.TransformDirection(Vector3.forward);
moveDirection*=speed;

if(c.isGrounded)
{
	if(Input.GetButton("Jump"))
		{
			vel.y=3.8;
		}
}
else
{
vel.y+=Physics.gravity.y*Time.smoothDeltaTime;
}

moveDirection+=vel;

c.Move(moveDirection*Time.smoothDeltaTime);
}

'cause I’m a noob and I found code for that :wink:

Before that it was constantForce, so it’s improving.

Thanks, I’ll try your code instead. (I’m starting to understand how code is laid out/what it means… but not enough just to type it up on my own yet- it’s only been about 2 weeks, but I’ve been modelling/map making for 10 years).

Thanks saurabh,

I did try it but I’m still learning scripting, so you have a few things like c.Move (not really sure how to use the c, should I make a variable, or is that short for something?

BTW, my character can’t jump. Flies like a plane, so wasd is up,left,right,down. That’s why I want the constant forward movement.

Does the c stand for characterController?