Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Feature requests and bug reports
New "Do Something Later" extension please?

sven
Registered User
Quote
2021-07-27 18:19:10

action_AnimateScale.js

// This is a scripted coppercube action.
// It scales an object animated to a specific target scale.
//
// The following embedded xml is for the editor and describes how the action can be edited:
// Supported types are: int, float, string, bool, color, vect3d, scenenode, texture, action
/*
<action jsname="action_AnimateScale" description="Animate Scale of 3D Object">
<property name="NodeToScale" type="scenenode" />
<property name="TimeMs" type="int" default="500" />
<property name="TargetScale" type="vect3d" default="2.0, 2.0, 2.0" />
</action>
*/

action_AnimateScale = function()
{
};

// called when the action is executed
action_AnimateScale.prototype.execute = function(currentNode)
{
var me = this;
this.registeredFunction = function() { me.scaleAnimFunc(); };

ccbRegisterOnFrameEvent(this.registeredFunction);

this.startTime = (new Date()).getTime();
this.endTime = this.startTime + this.TimeMs;
this.currentNode = this.NodeToScale;
this.startScale = ccbGetSceneNodeProperty(this.NodeToScale, "Scale");
}


action_AnimateScale.prototype.scaleAnimFunc = function()
{
var now = (new Date()).getTime();

if (now > this.endTime)
{
// ccbInvokeAction(this.ActionToDo, this.registeredFunction);
ccbUnregisterOnFrameEvent(this.registeredFunction);
ccbSetSceneNodeProperty(this.currentNode, "Scale", this.TargetScale);
}
else
{
var delta = (now - this.startTime) / this.TimeMs;
if (delta > 1.0) delta = 1.0;

var x = this.startScale.x + ((this.TargetScale.x - this.startScale.x)*delta);
var y = this.startScale.y + ((this.TargetScale.y - this.startScale.y)*delta);
var z = this.startScale.z + ((this.TargetScale.z - this.startScale.z)*delta);

ccbSetSceneNodeProperty(this.currentNode, "Scale", x, y, z);
}
}





action_DoLater.js

// This is a scripted coppercube action.
// It does an action somewhen later.
//
/*
<action jsname="action_DoLater" description="Do something later">
<property name="TimeMs" type="int" default="500" />
<property name="ActionToDo" type="action" />
</action>
*/

action_DoLater = function()
{




};

// called when the action is executed
action_DoLater.prototype.execute = function(currentNode)
{
var me = this;
this.registeredFunction = function() { me.doLaterFunc(); };

ccbRegisterOnFrameEvent(me.registeredFunction);

this.startTime = (new Date()).getTime();
this.endTime = this.startTime + this.TimeMs;
this.currentNode = currentNode;
}


action_DoLater.prototype.doLaterFunc = function()
{
var now = (new Date()).getTime();

if (now > this.endTime)
{
ccbInvokeAction(this.ActionToDo, this.currentNode);
ccbUnregisterOnFrameEvent(this.registeredFunction);
}
}



VP
Guest
Quote
2021-07-27 18:25:21

Yes, I commented out line 39 of the "Animate scale" script (not the "Do Later" script and reloaded the plugins..erorr says something like: "animate scale function not defined".

You're right though - anything with the animate scale script (if placed in the "before first draw") gets screwed up. Thanks for the help.


sven
Registered User
Quote
2021-07-27 18:28:11

ccbInvokeAction(this.ActionToDo, this.registeredFunction);

This line from your animate script is not needed.. it has nothing to do with animate function.. (its a result of copy & paste from do later script--leftover code part)


veganpete
Registered User
Quote
2021-07-27 18:28:12

̶I̶ ̶n̶o̶t̶i̶c̶e̶ ̶t̶h̶e̶ ̶a̶n̶i̶m̶a̶t̶e̶ ̶s̶c̶a̶l̶e̶ ̶s̶c̶r̶i̶p̶t̶ ̶c̶a̶l̶l̶s̶ ̶"̶d̶e̶l̶t̶a̶ ̶t̶i̶m̶e̶"̶ ̶-̶ ̶I̶'̶m̶ ̶n̶o̶t̶ ̶u̶s̶i̶n̶g̶ ̶t̶h̶e̶ ̶d̶e̶l̶t̶a̶ ̶t̶i̶m̶e̶ ̶p̶l̶u̶g̶i̶n̶ ̶(̶w̶h̶i̶c̶h̶ ̶I̶'̶v̶e̶ ̶s̶e̶e̶n̶ ̶s̶o̶m̶e̶w̶h̶e̶r̶e̶ ̶o̶n̶ ̶t̶h̶e̶ ̶f̶o̶r̶u̶m̶)̶ ̶-̶ ̶w̶o̶u̶l̶d̶ ̶t̶h̶i̶s̶ ̶b̶e̶ ̶c̶a̶u̶s̶i̶n̶g̶ ̶t̶h̶e̶ ̶i̶s̶s̶u̶e̶ ̶f̶o̶r̶ ̶m̶e̶?̶ ̶


veganpete
Registered User
Quote
2021-07-27 18:29:15

Ah, my mistake - I tried commenting it with a hash sign, not two slashes. I downloaded the animate scale extension from the official coppercube site - so I just assumed it would work without needing any editing. I'm brand-new to coding so had no idea it even had errors. Thank you!


sven
Registered User
Quote
2021-07-27 18:29:17

:D hopefully that fixes problem :D


veganpete
Registered User
Quote
2021-07-27 18:34:09

wrote:
:D hopefully that fixes problem :D


Awesome! Really appreciate your help at getting to the bottom of this - it was literally screwing up everything I tried to do and was driving me insane, lol.

I suggest Niko uploads your updated script to the coppercube site to prevent people experiencing the same problem in the future if they download the animate scale extension...

https://www.ambiera.com/coppercu...


just_in_case
Moderator
Quote
2021-07-28 12:52:16

glad that it is fixed now, so it wasn't related to do later action...


VP
Guest
Quote
2021-07-28 22:56:21

Well, yes and no really. Commenting out line 39 on the Animate Scale extension definitely seems to have fixed this particular glitch - still not sure if it's 100% fixed all the related issues yet (on the level-select, pyramid-maze and anubis animation) in relation to the move position, play sound, and restart scene bugs which I reported.

If it has, that's really great news for me as I can just drop the new script in to fix them all - and my game will be pretty much back to where it was instantly! . If not, I'll have to look through all those other scripts to see if they have similar function errors as the animate scale extension (I can then comment out those lines as well).

The reason I think it's related to "Do something later" extension is because I can workaround all the glitches by adding variable flags (as you suggested) to control the "do later " actions - and the bug ONLY ever occured when "Do something later" is used with "before first draw" - it never causes a problem at all if I don't use "Do something Later", or "Before First Draw", (even if I use the animate scale).

Hopefully this fixes all the problems in one - but even if it's not completely fixed, this is a massive step in the right direction.


just_in_case
Moderator
Quote
2021-07-29 02:16:52

When, I tried your suuplied .ccb file , I found that your project is glitched, I also found the node that you have there as a children of camera becomes the target of the camera.
Instead of being an individual mesh node.
This is really strange. Your project file seems to be messed up. I will look into this a bit.


VP
Guest
Quote
2021-07-29 08:49:15

Thank you! just_in_case I really appreciate any tips/fixes for the odd behaviours/glitches.


just_in_case
Moderator
Quote
2021-07-29 09:27:35

Hey there, I accidentally deleted the file, and now when I am trying to download it again via the link you provided it shows that the file is no longer accessible. The user has put the file in the trash. If you can reupload the file so that I can perform some tests.


sven
Registered User
Quote
2021-07-29 11:49:54

wrote:
When, I tried your suuplied .ccb file , I found that your project is glitched, I also found the node that you have there as a children of camera becomes the target of the camera.
Instead of being an individual mesh node.
This is really strange. Your project file seems to be messed up. I will look into this a bit.


Because this project useing "third person style camera"
and camera target is set to be "BUG" node (camera follow BUG)..

And BUG node has scale 0,0,0 so it seems to be not there but only camera target (in editor view).

Script animate do scale it from 0,0,0 to 20.0, 1.0, 20.0 (if removed the line from script) -this project file seems to be OK to me.
(there is no difference if i leave bug node as childern of camera or i make it an individual.)


just_in_case
Moderator
Quote
2021-07-29 12:20:28

@sven is right, It is an animate scale action error that was causing the bug, and he is also correct about tpp cam. I didn't look at the camera's behavior, I assumed it was the static camera. SIlly me heheheh sorry for causing any confusion.


VP
Guest
Quote
2021-07-29 22:34:17

Hey, no worries at all just_in_case , really appreciate both of your help!

Thank you [b] sven
as well... when it comes to coding/scripting - there's no chance I could have ever found or fixed the issue myself. I knew something was wrong but it was really awkward and confusing for me to figure out what was actually going wrong.

Everything seems to be working now without any issues so thanks a lot for everyone who offered support with these issues - especially as I couldn't really give any examples for anyone to work with.


Create reply:


Posted by: (you are not logged in)


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