Advanced Camera Follow Object
by Dustin Williams · in Torque Game Engine · 01/10/2005 (2:01 pm) · 14 replies
How do I assign an advanced camera to a projectile rather than the player?
(This would make it so that camera follows the projectile rather than the player.)
(This would make it so that camera follows the projectile rather than the player.)
#2
%this.advCamera.setPlayerObject(%projectile);
Naming could be better, but that should be exactly what you want
PlayerObject = the object you are looking at
01/10/2005 (10:52 pm)
If you are in e.g. 3rd person mode, then you just do this:%this.advCamera.setPlayerObject(%projectile);
Naming could be better, but that should be exactly what you want
PlayerObject = the object you are looking at
#3
%projectile = ________
part?
01/10/2005 (11:05 pm)
I've tried playing around with setPlayerObject, but I'm having trouble actually setting the projectile to variable in the first place. In your example, where would I put the%projectile = ________
part?
#4
If your projectile has a name, you can always use the nameToId() method.
Else it would depend a lot on your implementation inside the code. Is your projectile spawned by you manually - then its damn easy.
If its a projectile shot from a weapon, then you have several issues. What if the weapon fires again while you follow a projectile? Could you hack the weapon to return a "last shot projectile id" method?
All these would be the right part of the
%projectile = _____
formular
Cant really help you there. Its up to your implementation.
01/11/2005 (9:25 am)
Well - thats the trick, isnt it ;-)If your projectile has a name, you can always use the nameToId() method.
Else it would depend a lot on your implementation inside the code. Is your projectile spawned by you manually - then its damn easy.
If its a projectile shot from a weapon, then you have several issues. What if the weapon fires again while you follow a projectile? Could you hack the weapon to return a "last shot projectile id" method?
All these would be the right part of the
%projectile = _____
formular
Cant really help you there. Its up to your implementation.
#5
-->When a projectile is launched, set it to a global variable and initiate a change camera function.
-->In the change camera function set the camera to the global variable.
Would this work? How do I do this? The main part I'm fuzzy about is what I set the global variable to. What local varaible inside of what projectile function or datablock do I need to read from?
Thanks for your help!
01/11/2005 (10:05 pm)
Hmm, I didn't even think about that. I'm shooting the projectile with a weapon and I'd like the camera to follow the newest projectile. So I'm thinking that I want to assign the camera to the projectile right after the weapon launches it. Problem is, again, how would I go about assigning the newest projectile to the camera? How do I go about assigning a projectile to a variable in the first place? My thoughts are:-->When a projectile is launched, set it to a global variable and initiate a change camera function.
-->In the change camera function set the camera to the global variable.
Would this work? How do I do this? The main part I'm fuzzy about is what I set the global variable to. What local varaible inside of what projectile function or datablock do I need to read from?
Thanks for your help!
#6
01/12/2005 (7:39 am)
I don't think it'll work because the advanced camera's player/target objects are ShapeBases. Try making them GameBases to get it following projectiles.
#7
01/12/2005 (8:16 am)
Yeah - thats right Josh. I'll need to revise/clean up in the code a bit soon
#8
01/12/2005 (11:47 am)
Ahh, so that's why it's not working. How do I change it to GameBases? Or should I even bother? Would it be possible to attatch a invisible ShapeBase object to the projectile and have the camera follow that instead? Thanks for your help!
#9
Fix will be implemented soon in a small update to the adv camera. Got a few other things to add anyways (client side orbit camera mostly)
01/12/2005 (1:32 pm)
If you go into the code for the advanced camera, change all the method signatures and the variable for the player object from shapebase -> gamebase. Thats it (I hope).Fix will be implemented soon in a small update to the adv camera. Got a few other things to add anyways (client side orbit camera mostly)
#10
01/12/2005 (2:56 pm)
@Thomas - It's great to hear there will be more updates to the adv camera.
#11
How would I get the advCamera to follow Kork?
Or change targets in general?
I gave Kork a global id -
%player = new AiPlayer($kork) {etc }
Same for advCamera -
%this.advCamera = new AdvancedCamera($advCam) { etc}
In the console I try to change the advCamera target -
==>$advCam.setPlayerObject($kork);
(0): Unable to find object: '' attempting to call function 'setPlayerObject'
01/16/2005 (3:57 pm)
I've added the advCamera to the sdk example, and it works. How would I get the advCamera to follow Kork?
Or change targets in general?
I gave Kork a global id -
%player = new AiPlayer($kork) {etc }
Same for advCamera -
%this.advCamera = new AdvancedCamera($advCam) { etc}
In the console I try to change the advCamera target -
==>$advCam.setPlayerObject($kork);
(0): Unable to find object: '' attempting to call function 'setPlayerObject'
#12
So if you have a gameconnection in %this, then write %this.player.advCamera.setPlayerObject(%kork);
But you have a few scripting errors in your example. First $ makes a variable global. And %player = new AiPlayer($kork) {etc } will return the AiPlayer into %player - not into $kork.
01/16/2005 (10:31 pm)
If you followed the resource descriptions, in game.cs you then added the advCamera to %this - which was the %client.playerSo if you have a gameconnection in %this, then write %this.player.advCamera.setPlayerObject(%kork);
But you have a few scripting errors in your example. First $ makes a variable global. And %player = new AiPlayer($kork) {etc } will return the AiPlayer into %player - not into $kork.
#13
01/17/2005 (9:56 am)
EDIT - got a chance to try this again... works great.
#14
02/13/2005 (10:33 pm)
Today I moved the updated .cc and .h file for the advanced camera resource into my game directory and recompiled. It compiled and works fine, but I'm having trouble getting the camera to follow the projectile. In shapeBase.cs in ShapeBaseImageData::onFire I set $myprojectile to %p after %p is set to new (%data.projectileType) () {...} and in my code to fire my cannon set the advcamera to $myprojectile. When I fire and the adv camera is set to the projectile, I get a screen filled with the same color as my fog. What should I do now? Has anyone used advanced cameras with projectiles before? Is my pointer wrong?
Torque Owner Josh Albrecht
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5471
I'm sure you can modify it slightly to follow a projectile instead of a player.