Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name: Password:
Ambiera Forum > CopperCube > Programming and Scripting
i want animate rotation, help pls
Author Text

Registered User
2022-06-14 18:15:05

have this code:
/*	Info 

Extension Name : Rotate towards target
Extension Type : Action
Author: : Vazahat Khan (just_in_case)
Date Created : ??Don't remember
Description : It allows you to rotate your scnenode in the direction of the target node.

/* Donate

If you like my work, please consider "buy me a cup of coffee" to support me.
You can do that via PayPal :)



/* <action jsname="action_rotatetowardstarget" description="Rotate an object towards another object">
<property name="Scenenode" type="scenenode" />
<property name="Target" type="scenenode" />
<property name="AdditionalRotation" type="int" default="180" />

action_rotatetowardstarget = function()

action_rotatetowardstarget.prototype.execute = function(currentNode)

var position = ccbGetSceneNodeProperty(this.Scenenode, "Position");
var rotation = ccbGetSceneNodeProperty(this.Scenenode, "Rotation");
var pos_target = ccbGetSceneNodeProperty(this.Target, "Position");

var radians_Horizontal = Math.atan2(pos_target.x - position.x,pos_target.z - position.z);
var degree_Horizontal = (radians_Horizontal * (180 / Math.PI)) ;

ccbSetSceneNodeProperty(this.Scenenode,"Rotation",rotation.x, degree_Horizontal + this.AdditionalRotation, rotation.z);


// ***Author:- VAZAHAT PATHAN***

// ****AKA****

// ****Just_in_case****

It rotates the object immediately, I need it to rotate smoothly, animatedly, please help me to implement

2022-06-15 08:34:46

hi there, I just updated the action with the smooth rotation (animation) feature and a few more options like stopping the rotation towards the target with a variable and an option to make the object continuously rotate towards the target or rotate only once.

The updated action will be uploaded to the website in a few minutes.

The variable that can be used to stop the rotation is

here the player is the name of the scene node that is rotating towards a target node, to stop the rotation all you need to do is to set this variable to "false" and that's it.

Hope you like it.

2022-06-15 09:55:56

It is now available to download from the website.

Registered User
2022-06-15 14:36:48

thank you very much

Registered User
2022-06-18 11:50:32

But if I want to set this rotation to the character, then my character will scroll once more before looking towards the object or camera, and tell me an example of how to use a variable to stop the rotation

2022-06-18 15:24:02

Sorry, I didn't understand what does your character do? In order to stop the rotation. Just attach an action set a variable wherever you want the player to stop, like on proximity or on keypress simply set a variable.

suppose your player node name is Vazahat then you need to set the variable name to
and set its value to

so now it will stop the player with Vazahat name from rotating towards the target.

Registered User
2022-07-17 14:13:48

These plugins are great just_in_case. I'll use them in my game and make a "buy me a coffee" donation next time I get paid. The "look at target" is one I've used regularly. Thank you.

If you're interested in the idea... I could make a regular donation for you to make a simple plugin every month and release it to the Coppercube community and your Neophytes site. We could get ideas for plugin requests from the forum and discord server?

2022-07-17 16:28:50

Thanks @veganpete, I like the idea, but at the same time I am also afraid what If I will be not able to deliver extensions and plugins as per the requirements. I will be posting more stuff and working on improving the engine, If you want you can support me. but I am not sure, if I will be able to post things with respect to a time period. How about you can support me, when I release a plugin or extension and if you think that extension is helpful and useful to you. That way, you can still support me and it won't feel like you are sending coffees for nothing.


2022-07-17 19:04:23

Sure, no problem - didn't want to put you under pressure. I'll make a coffee donation to you when I'm paid next.

2022-07-18 11:49:36


do these forum'istas bother you ?

Vazahat.rotatetowardstarget = false; 

Create reply:

Posted by: (you are not logged in)

Enter the missing letter in: "Int?rnational" (you are not logged in)




Possible Codes

Feature Code
Link [url] [/url]
Bold [b]bold text[/b]
Image [img][/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]



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