Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
make node follow FP camera

coa
Guest
Quote
2022-01-20 09:31:02

Hi can someone tell me the best way to make node follow FP camera

there has been some discussion about this but the link is broken to the example.


just_in_case
Moderator
Quote
2022-01-20 15:20:27

watch this video by @sven, it might be the thing that you need.
https://www.youtube.com/watch?v=...


coa
Guest
Quote
2022-01-20 17:45:28

thanks I tried this script but it does not work for me the Game actors clones do not follow player when in range


coa
Guest
Quote
2022-01-20 18:38:10

the problem is probably because im using cloned nodes it works fine if im using just 1 note


coa
Guest
Quote
2022-01-20 19:24:50

Ive now test it with with clones and it worked fine but it does not work in my game im trying to figure it out


VP
Guest
Quote
2022-01-21 13:44:25

Depending which script you've used, you may need to "restart the behaviours of the node" because some AI plugins/scripts are coded to stop running or change mode, once the node reaches its target or if it goes out of range etc. Also the default Game Actor behaviour has an "on activate" radius option - this may be accidentally overriding/consfusing your script by trying to do something else whenever the node is activated by sanother node coming in/out range.

For example, I just use "every few seconds, move towards node" to move a game character node towards its target. I then use "on Proximity" to trigger that "follow" action on/off. Other people use more complex AI methods which will have different features.


coa
Guest
Quote
2022-01-21 17:04:36

thanks VP for the info .. where can i find the move towards node action ,, i cant see it


veganpete
Registered User
Quote
2022-01-26 08:13:12

Yeah, I can't find it either. Not sure where I got it from originally but here's the action I'm using (paste the entire thing into a text file and save it, rename the file extension from ".txt" to ."js", then place it in your "c:/user/documents/coppercube/extensions/" folder, then rescan your coppercube plugins or simply restart coppercube. Hopefully it will work for you....

/* <action jsname="action_MoveAIM" description="Move AI in direction of a Node">
<property name="TargetNode" type="scenenode" />
<property name="AOffset" type="float" default="5." />
</action>
*/

action_MoveAIM = function() {};

action_MoveAIM.prototype.execute = function(currentNode) {
var position = ccbGetSceneNodeProperty(currentNode, "Position");
var newpos = ccbGetSceneNodeProperty(this.TargetNode, "Position");

ccbAICommand(currentNode, "moveto", newpos);
var moveto = (newpos);
var mvec = moveto.substract(position);
mvec.normalize();
mvec.x=Math.round(mvec.x*this.AOffset);
mvec.y=Math.round(mvec.y*this.AOffset);
mvec.z=Math.round(mvec.z*this.AOffset);
ccbAICommand(currentNode, "moveto", moveto.add(mvec));
}

/*
Action created by:
Dude
*/



coa
Guest
Quote
2022-01-26 08:40:56

I get this error text when rescan plugin
On the script you posted

Ignoring extension file 'movetowardsnode.js' because it doesn't start with 'behavior_' or 'action_'.

I dont know how to fix this


veganpete
Registered User
Quote
2022-01-26 08:48:16

No worries, simply rename the file as: action_movetowardsnode.js


coa
Guest
Quote
2022-01-26 09:11:40

thanks. I dont know if ill be using this action right now but maby some day... one think is baffling me is it possible to somehow to trigger the movetowardnode action with on proximity on individual nodes cloned with the action clone a scene node.

if I use a variable to trigger the action all clones start to movetowardnode


veganpete
Registered User
Quote
2022-01-26 09:38:30

Yes, it's possible, I've successfully done it in my Cas-Evac game. I can't code yet, so after a lot of thinking, I came up with a "cheat" solution to allow hundreds of clones to follow and attack the player whilst using very little resources and zero coding - so it's very quick and simple to set up (and also easy to make changes)....

This method (Let's call it VP's switcheroo method) requires just 2 enemies to be set up.

I have one main "attacker" enemy with all the complex A.I. functions (such as attack, follow, change animations etc). I then hide this away (make invisible and move to position 0,-5000,0). We'll keep him hidden away here until later.

Now I make a secondary "hunter" enemy (which will be cloned throughout the game). This secondary enemy has no A.I. at all - only a basic "random patrol" (to move it around the scene) and an "on proximity" to interact with the enemy.

The clever bit is this "on proximity" instruction... Whenever one of the "Hunter" enemy clones comes in "proximity of the player", I just swap this "hunter" clone's (current node) with the main "attacker" enemy's node - which then takes over with the A.I. to attack and follow the player etc. This gives the illusion that every clone can attack and follow the player, when in fact none of them can.

.....So all the clones have the "on proximity", swap position with Main Enemy" instruction - only the main enemy has the attack/follow commands, so there's never any confusion with which one should attack - there's literally only ever one node which can attack, no matter how many clones there are in the scene.

Now, once I have these 2 enemies set up, I can make a spawner to clone these basic secondary enemies over and over - they roam around looking for the player and whenever they come near the player, they swap with the main enemy who takes over with the attacking - but there's only ever really 1 main enemy that attack the player - it gets swapped with whichever clone finds the player first and perfectly creates the illusion of hundreds of A.I. enemies. lol.

I label these enemies as "Hunter" and "Attacker"

Only thing is when you "switch" the enemies, you must use the "move without command "function otherwise the enemies will get stuck on your terrain/buildings etc and not swap positions.

*Not by swap position, I mean move "Attacker" enemy to relative position (0,0,0) of "Current Node" hunter enemy, then hide the current node "Hunter" enemy.

**Once it's all working - to make it more convincing, you can also have a "Dead Body" clone and use the same technique to add dead bodies. When the main "Attacker" node is killed, switcheroo the "Attacker" node with a cloned "Dead Body" node, so the scene becomes littered with dead bodies.

Hope this makes sense. If not, I can upload a ccb example when I get time.


coa
Guest
Quote
2022-01-26 10:16:09

Yeah i get it I think very nice solution
but will the hunter enemy be unkillable?


VP
Guest
Quote
2022-01-26 10:49:40

You can kill the hunter clones by having a "delete current node" with the "on proximity" to player.

When the "Attacker" node is killed, don't delete it, just move it to 0,-5000,0 again so it can be re-used again by the next clone.


coa
Guest
Quote
2022-02-05 10:05:56

thanks for all help
i dont know if ill be using this technique but maybe someday.


quote
You can kill the hunter clones by having a "delete current node" with the "on proximity" to player.


yes i know that but i mean i cant shoot the hunter down because he does not have a link to attackers health variable


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inter?ational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact