Skip to content

Commit

Permalink
fix turning to face when just finished walking
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmacartney committed Aug 16, 2023
1 parent 04e7d67 commit f03478f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions convex/journal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,12 @@ export const turnToFace = internalMutation({
handler: async (ctx, { playerId, targetId }) => {
const us = await getLatestPlayerMotion(ctx.db, playerId);
const them = await getLatestPlayerMotion(ctx.db, targetId);
if (us.type !== 'stopped') throw new Error("Can't turn while moving");
const targetPos = them.type === 'stopped' ? them.pose.position : them.route.at(-1)!;
us.pose.orientation = calculateOrientation(us.pose.position, targetPos);
if (us.type === 'stopped') {
us.pose.orientation = calculateOrientation(us.pose.position, targetPos);
} else {
us.endOrientation = calculateOrientation(us.route.at(-1)!, targetPos);
}
await ctx.db.insert('journal', {
playerId,
data: us,
Expand Down
2 changes: 1 addition & 1 deletion convex/lib/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export const getReflectionMemories = internalQuery({
)
.order('desc')
.take(numberOfItems);
console.debug('conversation memories lenth', conversations.length);
// console.debug('conversation memories lenth', conversations.length);
const reflections = await ctx.db
.query('memories')
.withIndex('by_playerId_type', (q) =>
Expand Down

0 comments on commit f03478f

Please sign in to comment.