ambiera home ambiera home

Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name:  Password:
Ambiera Forum > CopperCube > Help with CopperCube
Moving platforms (which you can stand on)?
Author Text

j9907
Registered User
Quote
2018-11-15 03:25:25

How do I make platforms which follow a path (it goes up and down) and allow the character to stand on it and you can travel up with it? It doesn't work...


tim12345
Guest
Quote
2018-11-15 04:07:15

currently that is not supported right out of the box. gotta program it, unfortunately!


j9907
Registered User
Quote
2018-11-15 04:08:38

Ah, darn it. Hmm.... What a shame! I'll have to modify the level a bit to get around this (sad) limitation I suppose...


cerrone
Registered User
Quote
2018-12-08 23:27:22

Add collision and the behavior below, it's the behavior from the documentation.
It works only with two path points.

/*
<behavior jsname="behavior_moveBetweenPoints"
description="Move scene node between 2 points">
<property name="EndPoint" type="vect3d" default="100.0, 100.0, 100.0" />
<property name="Speed" type="float" default="0.02" />
</behavior>
*/

behavior_moveBetweenPoints = function()
{
this.LastTime = null;
this.StartPoint = null;
};

// called every frame.
// 'node' is the scene node where this behavior is attached to.
// 'timeMs' the current time in milliseconds of the scene.
// Returns 'true' if something changed, and 'false' if not.
behavior_moveBetweenPoints.prototype.onAnimate = function(node, timeMs)
{
// get the time since the last frame

if (this.LastTime == null)
{
// we were never called before, so store the time and cancel
this.LastTime = timeMs;
this.StartPoint = ccbGetSceneNodeProperty(node, 'Position');
return false;
}

var delta = timeMs - this.LastTime;
this.LastTime = timeMs;
if (delta > 200) delta = 200; // never do movements longer than 200 ms

// move

var pos = ccbGetSceneNodeProperty(node, 'Position');

var movementVector = this.EndPoint.substract(this.StartPoint);

if (pos.substract(this.StartPoint).getLength() > movementVector.getLength())
{
// end point reached, switch direction and restart

var tmp = this.StartPoint;
this.StartPoint = this.EndPoint;
this.EndPoint = tmp;

movementVector = this.EndPoint.substract(this.StartPoint);
}

// move

movementVector.normalize();

pos.x += movementVector.x * delta * this.Speed;
pos.y += movementVector.y * delta * this.Speed;
pos.z += movementVector.z * delta * this.Speed;

// set new position

ccbSetSceneNodeProperty(node, 'Position', pos);

return true;
}


santito
Registered User
Quote
2018-12-11 00:22:07

I have been trying to do something similar to this also.

@cerrone: Wow, that is one heck of a script you got there. I am somewhat of a newbie when it comes to scripts, so I am wondering if I can ask you a favor: Is there a possibility you can make a very simple scene of a working example of this script in action? Nothing too fancy, just the camera and a moving platform, that's all. And once you have it done, I will really appreciate a lot if you were to post a download link to the actual CopperCube file(.ccb). By looking at the CopperCube file and studying carefully, I can get a better grasp on how everything works and comes together.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internatio?al" (you are not logged in)


Text:

 

  

Forum 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


   





Software: Ambiera Light Forum. © 2008-2019 Nikolaus Gebhardt, Ambiera e.U.