Skip to content

Commit

Permalink
Skill effect: Ball forward is according the camera (#38)
Browse files Browse the repository at this point in the history
* fix textureMode, size and position

* fix: ball forward is camera forward now

* fix format
  • Loading branch information
sdilauro authored Aug 30, 2024
1 parent d21fc23 commit ad540fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
7 changes: 3 additions & 4 deletions scene/src/enemies/monsterAttackRanged.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let arrows: ArrowType[] = []
export function shootArrow(distance: number = MAX_DISTANCE): void {
const arrowEntity = entityController.addEntity()
const playerPosition = Transform.get(engine.PlayerEntity).position
const playerRotation = Transform.get(engine.PlayerEntity).rotation
const cameraRotation = Transform.get(engine.CameraEntity).rotation

GltfContainer.create(arrowEntity, {
src: 'assets/models/GreenOrb.glb',
Expand All @@ -31,16 +31,15 @@ export function shootArrow(distance: number = MAX_DISTANCE): void {

Transform.create(arrowEntity, {
position: playerPosition,
rotation: playerRotation
rotation: cameraRotation
})

// Calculate the forward direction and set the initial position
const forward = Vector3.rotate(Vector3.Forward(), playerRotation)
const forward = Vector3.rotate(Vector3.Forward(), cameraRotation)
const arrowStartPosition = Vector3.add(
Vector3.scale(forward, 0.5),
playerPosition
)

const newArrow: ArrowType = {
entity: arrowEntity,
startPosition: arrowStartPosition,
Expand Down
12 changes: 8 additions & 4 deletions scene/src/ui/dungeon/dungeonComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,16 @@ function Dungeon({
>
<UiEntity
uiTransform={{
width: canvasInfo.width * 0.1,
height: canvasInfo.width * 0.1,
display: isOpen ? 'none' : 'flex'
width:
canvasInfo.width * 0.1 > 100 ? 100 : canvasInfo.width * 0.1,
height:
canvasInfo.width * 0.1 > 100 ? 100 : canvasInfo.width * 0.1,
display: isOpen ? 'none' : 'flex',
positionType: 'absolute',
position: { top: '50%', right: 20 }
}}
uiBackground={{
textureMode: 'center',
textureMode: 'stretch',
texture: { src: 'assets/images/dungeon.png' }
}}
onMouseDown={openDungeonSelection}
Expand Down

0 comments on commit ad540fc

Please sign in to comment.