No, it’s not, if you can’t avoid it. It’s a sin when you kill people for getting in your way. On war or when they attack you and it’s either you kill or get killed, it isn’t a sin. It wouldn’t be a sin if you killed someone attempting to murder or rape someone else, if you weren’t able to incapacitate him otherwise. The life of the innocent victim has to matter more than the life of the assailant who has already made his decision. It’s a sin to enjoy watching people suffer. It’s also a sin carelessly to provoke situations that may result in you having to hurt someone.