> For the complete documentation index, see [llms.txt](https://ss3d.gitbook.io/design/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ss3d.gitbook.io/design/entities/combat/melee-combat.md).

# Melee combat

## Range and Arc

Different melee weapons have a different range and arc of reachable targets. A spear can reach far, but with a very narrow angle. A hammer has low range but with a wider arc of reachable target.

Below is a picture of a stun baton and a bat, and their respective arc and range.\
\ <img src="/files/JokYRlHbR3NaXmMOdZii" alt="" data-size="original">

## Selecting targets in melee combat

Aiming in SS3D implies two things :

* Selecting a target entity.
* Selecting a body part on this entity.

### Selecting a target entity in combat mode

Attacking a player happens when left clicking, therefore, click position matters to determine which entity to target.

First, an entity must be reachable to be targeted, meaning it must be in the area determined by Range and arc of the melee weapon.

#### Clicking directly on reachable entity

This one is simple, if the target is reachable and the click is on the entity, the entity is selected.

#### Clicking outside of arc and range

If the click occurs outside of arc and range of the weapon, the selected entity will be one that :

* Is reachable.
* Is the closest from the player.

#### Clicking inside of arc and range

If the click occurs inside arc and range, even with a reachable entity, the target will be whatever was clicked on. This allow to smash an item (or just the ground) in close proximity of another player.

### Selecting a target entity out of combat mode

Out of combat mode, selecting a target relies solely on the interaction system, it therefore implies clicking on the target, and some checks are done to verify if the hitting interaction can occur.

Here's a drawing to sum it up : (This one assumes direction of aim is following player's rotation, look at the **aiming's direction** part for more details on this particular point)

<figure><img src="/files/P1LkcF8JpqAYkQFdXHpp" alt=""><figcaption></figcaption></figure>

### Selecting a target body part

The consensus is that it's simpler for now to simply use the targeting doll to select the body part one's want to hit.

The targeting doll allows one in the UI to select any given body part on a humanoid character. In case where one of those body part would be missing, the next closest body part would be selected (missing right hand and right hand selected -> hit right arm).

## Aim's direction

In combat mode, the direction of hitting should follow the mouse, it's independent from character's body rotation (note that in this mode the character is strafing).

## Timing

Timing refers here to the time it takes between choosing a hit interaction, and landing the hit.

A simple solution could be first to reduce this time to zero. However, we might note that it'd be hard to make sense of animations if a player takes a hit before the swinging animation of the weapon even started. This is a point to consider, ongoing discussion.

## Movement in combat mode

In combat mode, strafing will be the main way of moving around, with the player's torso direction following the mouse cursor.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ss3d.gitbook.io/design/entities/combat/melee-combat.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
