Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Spawning enemies ahead of the player

Author
Message
Opposing force
20
Years of Service
User Offline
Joined: 10th Aug 2005
Location: England
Posted: 22nd Aug 2011 00:43
Forgive me for asking what would probably be a simple task. I admit I'm not good at maths, never have been. Okay, basically I have a system in place that re-spawns enemy characters when they're killed or when the player evades them. The problem I'm having is spawning them so they're ahead of the player.

I just can't get my head round this, it needs to take the angle of the player into account so they always spawn infront. Imagine a straight line from the player's point of view going off into the horizon. The enemy characters need to spawn 300 unit ahead and on that line. I'm really hoping that I don't need to use raycasting to accomplish this but if anyone can help me out that'd be great.
Mugen Wizardry
User Banned
Posted: 22nd Aug 2011 00:46
object position z(theplayer)+50 (add 50 units in front of the player)

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
Opposing force
20
Years of Service
User Offline
Joined: 10th Aug 2005
Location: England
Posted: 22nd Aug 2011 00:50
Yeah, I tried that but it doesn't take the player's angle into account so if the player turns round 180, they'll then spawn behind him.
Mugen Wizardry
User Banned
Posted: 22nd Aug 2011 00:53
if not object angle y(theplayer) < 0 then object position z(theplayer)+50 try that

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 22nd Aug 2011 01:06
Avoiding maths, this is one of doing this:

Opposing force
20
Years of Service
User Offline
Joined: 10th Aug 2005
Location: England
Posted: 22nd Aug 2011 01:20
The move command that was the little reminder that got my brain working. What can I say, I rewrote my code with your example as a guide and I got them spawning exactly as I needed. Thanks a lot 29 games.

Login to post a reply

Server time is: 2026-07-10 12:03:02
Your offset time is: 2026-07-10 12:03:02