≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Out of memory
Posted by:
(you are not logged in)
Enter the missing letter in: "Intern?tional"
(you are not logged in)
Text:
[quote][b]fantasy[/b] wrote: In my test level (Windows, physics on) I have added various things to the standard behaviours, like multiple stand/idle, attack, hit and die animations. At first look everything works fine. But - depending on the number of NPCs/enemies - after 18 to 50 minutes the game crashes down to 1 - 3 frames per second and I get a lot of "out of memory" errors in my scripts. An example with 2 fishes, who swim around and flee, if the player comes too close let's the game crash after around 50 minutes. Besides "Game Actor with Health" (randomly patrol) and "Collide when moved" the fishes have the following script: [code]// The following embedded xml is for the editor and describes how the behavior can be edited: // Supported types are: int, float, string, bool, color, vect3d, scenenode, texture, action /* <behavior jsname="behavior_wlEntityMoveNoGravNoKill" description="Entity no gravitation no kill"> <property name="WalkAnimation" type="string" default="walk" /> <property name="RunAnimation" type="string" default="run" /> <property name="DieAnimation" type="string" default="die" /> <property name="Fly" type="bool" default="false" /> <property name="EscapeDistance" type="int" default="40" /> <property name="WalkSpeed" type="int" default="7" /> <property name="RunSpeed" type="int" default="20" /> </behavior> */ behavior_wlEntityMoveNoGravNoKill = function() { this.LastTime = null; this.InitHeight = null; this.MyPos = null; this.Animation = null; this.MyName = null; this.MyVariable = null; this.SpeedName = 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_wlEntityMoveNoGravNoKill.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.InitHeight = ccbGetSceneNodeProperty(node, 'Position'); this.MyName = ccbGetSceneNodeProperty(node, 'Name'); this.Animation = ccbGetSceneNodeProperty(node, 'Animation'); this.MyVariable ="vx"+this.MyName; this.SpeedName = ""+this.MyName+".movementspeed"; return false; } //ccbSetCopperCubeVariable(name, -1); this.MyPos = ccbGetSceneNodeProperty(node, 'Position'); var player = ccbGetSceneNodeFromName("Player1"); var playerpos = ccbGetSceneNodeProperty(player, 'Position'); //calculate distance var dx = playerpos.x - this.MyPos.x; var dy = playerpos.y - this.MyPos.y; var dz = playerpos.z - this.MyPos.z; var dist = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2) + Math.pow(dz, 2)); this.Animation = ccbGetSceneNodeProperty(node, 'Animation'); //walk and escape if ((dist > this.EscapeDistance + 5) && this.Animation != this.WalkAnimation && this.Animation != this.DieAnimation) { ccbSetCopperCubeVariable(this.SpeedName, this.WalkSpeed); ccbSetSceneNodeProperty(node, "Animation", "None"); ccbSetSceneNodeProperty(node, "Animation", this.WalkAnimation); //ccbPlaySound("ding1.wav"); } if (dist < this.EscapeDistance && this.Animation != this.RunAnimation && this.Animation != this.DieAnimation) { ccbSetCopperCubeVariable(this.SpeedName, this.RunSpeed); ccbSetSceneNodeProperty(node, "Animation", "None"); ccbSetSceneNodeProperty(node, "Animation", this.RunAnimation); } //Correct Y-position if (!this.Fly) { /* if (this.MyPos.y > waterlevel - 3 && dist > this.EscapeDistanc[/quote]
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