Game Development Community

Need help with automated player movement.

by James Kelly · in Torque 3D Beginner · 12/11/2011 (7:40 pm) · 6 replies

I'm working on a game as a final project for my game design class. My current task is to make the player automatically follow a path once spawned. I.e. The only control the user would have over the player is to look around and shoot. I've looked at the AI movement in the RTS example but that is for moving to one specified spot. How would I make the player move automatically?

Basically, As soon as the player spawns, WASD should be disabled and the player should start moving around a pre-specified path at a set speed. I'm lost as to how to do this.

About the author

Recent Threads


#1
12/11/2011 (11:10 pm)
I think there are paths in the editor, which you can let the AI follow. never trid myself, but i read about it in the forums. Sorry for not being a better help, but search for paths and I think there should be some answers.
#2
12/12/2011 (8:55 am)
You can treat the player as an aiPlayer.
If you need some improvements on the player class,contact me at: ivanm (at) liman3d.com
I've already done a similar solution for a project.
#3
12/12/2011 (11:11 am)
As Ivan said, it sounds like your best bet is to move some of the AIPlayer code into Player (specifically, the movement parts of getAIMove). If you don't have source access as part of your class, you might want to see if someone on here can send you a modified binary, or consider something tricky like mounting your Player to a pathed Camera.
#4
12/12/2011 (11:39 am)
Unfortunately, my class does not have source code access. We are limited to the demo that's available to anyone. I had a thought. We were planning on integrating a cart into the player model and having that move around. Would I be able to spawn the cart as an AIplayer class and just move that around and have the player stand inside? If so, how would i go about doing that. I'm very new to torque and game programming in general.
#5
12/12/2011 (12:42 pm)
Look in (scripts) AiPlayer.cs - there is a stock system to spawn an AiPlayer class (like RTS tut) and have it run around, following a loop of markers on a path. It's called AiManager, it's at the bottom.

You need a simGroup called "Paths", a path object called "Path1" and as many path markers as you want inside of the Path1 folder/pathObject, placed wherever you want.

Then in gamecore.cs in the "startgame" function add:
//    // Start the AIManager
    new ScriptObject(AIManager) {};
    MissionCleanup.add(AIManager);
    AIManager.think();

and in "endgame" function add a cleanup script
//    // Stop the AIManager
    AIManager.delete();

Done correctly an AiPlayer will spawn from the stock scripts and run about your path.
#6
12/13/2011 (12:24 am)
Sounds like AiPlayer needs to be the control object, then?? How would you go about that?