Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
a new action.

carlosm
Registered User
Quote
2019-11-09 16:57:57

Hello everyone,

I am trying to offset an object with an action I did.
but he simply jumps from where he should go.

I didn't do a behavior so I didn't use the "onAnimate" prototype. but an action would like a tip on how to smoothly move the object from point A to point B.

The code I used was this:


delta var = 200;
var speed = 0.02;
var player1 = ccbGetSceneNodeFromName ("player_1");
var pos_1 = ccbGetSceneNodeProperty (player1, "Position");

var mob1 = ccbGetSceneNodeFromName ("Mob_1");
var pos_mob = ccbGetSceneNodeProperty (mob1, "Position");

var move_Vector = pos_1.substract (this.pos_mob);
print (move_Vector);
//
move_Vector.normalize ();

   this.pos_mob.x + = move_Vector.x * delta * speed;
   this.pos_mob.y + = move_Vector.y * delta * speed;
   this.pos_mob.z + = move_Vector.z * delta * speed;

  // set new position
ccbSetSceneNodeProperty (mob1, 'Position', this.pos_mob);



The scene is this: When the player approaches him
He changes his animation, and goes in the direction of the player.
but it simply jumps to the location of the player I want to move in a vector like behavior that has coppercube itself.

Else I used javascritp's native function and the editor as undeclared function! We don't have access to javascript api?

if anyone helps or gives a tip thanks.



Zoo
Guest
Quote
2019-11-10 19:09:02

A tween plugin already in coppercube...I believe that it is default


carlosm
Registered User
Quote
2019-11-11 04:11:56

Yes, I took the behavior and created an action for the dangers that may stalk or steal, I'm almost done.

I expressed myself bad I did not want a behavior but an action. and there is no ccb, so between how the behavior and how to do an action like this

Thanks for answering.


just_in_case
Moderator
Quote
2019-11-11 05:45:52

Maybe register_on_frame_event can help you.

OnAnimate and register_on_frame_event is something similar which run your code when the frame is changed or you can say every few seconds.


carlosm
Registered User
Quote
2019-11-12 04:58:33

Yes, I'm using it.
thanks good tip. ! just_in_casa.

I'm having problems with the game I'm making ...
on android sometimes the character texture appears on the water shader.

when the texture does not appear out of nowhere in the scenery simply the screen turns blue sometimes yes and sometimes no!
I will put the text memsl in bugs ..

I believe this happens because of an error in loading the game's assets or texture or the way it loads or the way it is compiled the game does it well I don't know.

I will try to compress with plugin if after disssocontinua I'm being forced to look outea engine the problem is that I like coppercube.


Create reply:


Posted by: (you are not logged in)


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