EDIT: figured out how to add screenshots. i have one more i need to add but it wont let me on this post. picture 3 is trump.png being outside of the map on the positive Y axis, while the flames.png has only slightly moved up in the Y axis (but and odd thing is the transform of trump increases in Y, whereas flames decreases in Y, but they both go in the same direction)
I have 2d game, with a parent object with two sprite children, a man moving up and down with a flamethrower. Currently having only the movement script and rigidbody, i can move the parent easily with arrowkeys. this moves the man and the flames at the same time.
If I add a box/circle/polygon/edge collider around the flames and press play, the man will move up and down normally, but the flamethrower only moves in discrete intervals, about 1/100 the distance that the man travels.
My goal is to have the flames interact with the enemies (and not ledges) to destroy enemies. Here is the code for the movement if it matters.
using UnityEngine;
using System.Collections;
public class TrumpController : MonoBehaviour {
private Rigidbody2D rg;
public float moveSpeed;
float speed ;
public float speedX;
// Use this for initialization
void Start () {
rg = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update () {
//player movement
MovePlayer(speed);
//left
if(Input.GetKeyDown(KeyCode.DownArrow))
{
speed = -speedX;
}
if(Input.GetKeyUp(KeyCode.DownArrow))
{speed = 0f;}
//right
if(Input.GetKeyDown(KeyCode.UpArrow))
{speed = speedX;}
if(Input.GetKeyUp(KeyCode.UpArrow))
{speed = 0f;}
}
//adds velocity in y direction for controlling trump based on
void MovePlayer(float playerSpeed)
{
rg.velocity = new Vector3(0f, speed, 0f);
}
public void WalkUp()
{
speed = speedX;
}
public void WalkDown()
{
speed = -speedX;
}
public void StopMoving()
{speed=0f;
}
}