Question by
Psilocybe · Dec 07, 2015 at 08:38 AM ·
2d game2d-physicsbomb
Problem getting dropped bombs to behave properly
I have a script which makes bombs dropped from the player (an aeroplane) travel forwards slightly (forwards being left or right) as they fall, which is the effect I'm after, but if I change the direction of the player after releasing a bomb, the bomb changes direction with the plane, which is obviously not what I'm after at all... Here's the script.
How can I get the bombs to stop following the player's movement after being dropped?
#pragma strict
var speed: float;
private var xvel: float;
private var rb: Rigidbody2D;
function Start () {
rb = GetComponent.<Rigidbody2D>();
}
function FixedUpdate () {
xvel = Input.GetAxis("Horizontal");
rb.velocity = Vector3(xvel * speed, rb.velocity.y);
}
Comment
Your answer
Follow this Question
Related Questions
2D Collision Problems... 0 Answers
How do I keep my player colliders from thinking that the player is in the air. 0 Answers
Unity2D Move character in tile increments with collision 1 Answer
How do I assign a velocity to an object on only 1 axis? 1 Answer
I need help with AI,Force not working 0 Answers