Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Announcements and Showcase
Pet follow

o139
Registered User
Quote
2024-01-03 14:33:38

Here is a pet follow script if anyone need it.. just put it on pet every 3000ms execute javascript

note both the player and pet must have actor behavior

note you must change the name dragon1 and player1 to your own name nodes

dragon = ccbGetSceneNodeFromName("dragon1");
pos1 = ccbGetSceneNodeProperty(dragon, "Position");

player = ccbGetSceneNodeFromName("player1");
pos2= ccbGetSceneNodeProperty(player, "Position");

distance = pos1.substract(pos2).getLength();

if(distance>10){
ccbAICommand(dragon, "moveto", new vector3d(pos2.x, pos2.y, pos2.z));

}



its possible to invert the distance to get a moveto player when range is <x meters.. behavior

happy coding and cheers!!


andgameplay
Registered User
Quote
2024-01-03 16:52:43

Thanks for share 0139, you are very good coder!


o139
Registered User
Quote
2024-01-03 21:03:43

your welcome and thanks for saying that..


blackwater
Registered User
Quote
2024-01-04 12:43:46

Thanks for sharing that! Will surely be to good use for many of us :D


o139
Registered User
Quote
2024-01-04 13:55:59

your welcome blackwater! and glad you think so.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internatio?al" (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