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.

Newcomers DBPro Corner / rotate enemy towards player in FPS

Author
Message
Qweeg
20
Years of Service
User Offline
Joined: 23rd Sep 2004
Location: Kent
Posted: 1st Nov 2004 05:51
I am working on FPS and am trying to get an enemy to face the player and move towards him when the two are close enough. I am using the AlienHive direct x object that comes with dark matter, and can get the enemy to move towards the player using the:

POINT OBJECT command (pointing it towards the main camera since this is the player). Then the move object to move the enemy closer to the camera. And this is fine as far as it goes

However for some reason the enemy object is facing away from the camera (although it moves correctly towards it). So when I play a set of animation frames for the enemy attack you can't see what is happening.

I have tried using commands like "yrotate" and "turn object left" before the "point object" command, but it doesn't seem to make any difference. And if I use these after the "point object" then the enemy moves the wrong way; and if I don't use the point object command at all but use something like yrotate instead, the enemy just spins round.

This must be because I should only be rotating the enemy if it isn't facing the camera, but I am not sure how to calculate that.

Any help on this would be much apreciated. I have attache a small snippet of my code.

many thanks,
thinkdigital
21
Years of Service
User Offline
Joined: 18th Oct 2003
Location:
Posted: 1st Nov 2004 06:32 Edited at: 1st Nov 2004 06:35
In the beginning of the program, before the main loop, type something like

yrotate object x,90
fix object pivot x

where x is the number of the enemy object.

Then point him in the loop and see if it works.

"Never put off for tomorrow what you can put off for the day AFTER tomorrow..."

eGeneric Works DB site - www.egenericworks.com
Qweeg
20
Years of Service
User Offline
Joined: 23rd Sep 2004
Location: Kent
Posted: 1st Nov 2004 07:19
Thanks for the quick response TD. I think the fix object pivot might be the thing I need. I will have a play with this tomorrow.

thinkdigital
21
Years of Service
User Offline
Joined: 18th Oct 2003
Location:
Posted: 1st Nov 2004 07:58
You bet. All the fix object pivot does, by the way, is set the object's current rotation as it's default one.

"Never put off for tomorrow what you can put off for the day AFTER tomorrow..."

eGeneric Works DB site - www.egenericworks.com

Login to post a reply

Server time is: 2024-11-27 15:48:50
Your offset time is: 2024-11-27 15:48:50