When my friend randomly suggested that we try a very ambitious hiking route, I knew it would absolutely suck if I didn't train for it. I got a gym membership and told myself I'd at the very least set foot in the gym 7 days a week for the first few weeks, just to build the habit of going. I was motivated to make sure I didn't slack off and ruin the hike for the group by being undertrained. A few months of that and the hike went great.
When we got back, though, I found it felt weird to not go to the gym in the mornings before work (as a decidedly NON-morning person my friends and family looked at me like I'd grown a second head when they heard me say I was working out before work). I started running outside on days the gym was crowded, and it felt good! In the nearly eight years since then, there have been only a handful of weeks where I didn't go for a run—I genuinely really enjoy it, no motivational tricks required.