0 votes

Dear community,

I am working on a gory 2D sprite based hack and slash sidescroller. I already figured out how to paint wails / ceilings / floors with blood texture and how to implement blood particles.

One thing I can't get my mind around is how I would achieve something like throwing a spear which collides with the enemy, sticks where it hit the enemy sprite and once the enemy dies can be collected by the player again.

This is basically two problems in one:
- How to have items with physics that the player can hold, throw and collect (swords, flashbangs, spears, arrows, whatever)
- How to make something attach to an enemy sprite

I am happy about any suggestion where to look for a solution or which tutorial to watch.

Godot version 3.2.3
in Engine by (15 points)

1 Answer

+1 vote
Best answer

Hi,

I am not very experienced on godot and coding in general but here are my two cents on your questions :

  • Throwing a spear is basically like shooting with a gun. There are many tutorials with this (shooting guns). I would instantiate an object with a collisionbody and a trajectory. When you throw, your character sprites change to spearless (I would required a set of sprite with and without spear).

  • When it collide with the enemy , you can get the coordinates and plant a spear as collectable there. Or change your enemy sprite to a "pined sprite with a spear on it" that would provide the player with a new spear if the player collides with it.

It may be suboptimal but that would be the way for me to do it.

Sorry for the poor english though, I feel sleepy :D

by (80 points)
selected by

I really like the logic you came up with, my thoughts on the topic were way more complicated. Thank you!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.