≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Problems with dash ability
Posted by:
(you are not logged in)
Enter the missing letter in: "Internat?onal"
(you are not logged in)
Text:
[quote][b][/b] wrote: Final code that i had was: ( i removed h0 ) [code]/* <action jsname = "action_rDash" description = "R--Dash mechanic for BSG"> <property name = "Plr" type = "scenenode"/> <property name = "JumpPower" type = "int" default="150"/> <property name = "DashSpeed" type = "Int" default="12"/> </action> */ action_rDash = function() { } action_rDash.prototype.execute = function() { if(ccbGetCopperCubeVariable("OnGround")==0) { return 0;//exit because player not on floor so probably function already running. } this.t0 = (new Date()).getTime(); var Rotation = ccbGetSceneNodeProperty(this.Plr, "Rotation"); this.DistX = Math.sin(Rotation.y * (Math.PI / 180)); this.DistZ = Math.cos(Rotation.y * (Math.PI / 180)); var me = this; this.RegisteredFunction = function() { me.Dash(); }; ccbRegisterOnFrameEvent(this.RegisteredFunction); } action_rDash.prototype.Dash = function() { var t1 = (new Date()).getTime(); var t = (t1 - this.t0) / 1000; var Pos = ccbGetSceneNodeProperty(this.Plr, "Position"); Pos.x += this.DistX * this.DashSpeed; Pos.y += this.JumpPower * t - (900 * t * t) / 2; Pos.z += this.DistZ * this.DashSpeed; ccbSetSceneNodeProperty(this.Plr, "Position", Pos); var Target = ccbGetSceneNodeProperty(this.Plr, "Target"); Target.x += this.DistX * this.DashSpeed; Target.y += this.JumpPower * t - (900 * t * t) / 2; Target.z += this.DistZ * this.DashSpeed; ccbSetSceneNodeProperty(this.Plr, "Target", Target); //HERE ADD YOUR OWN COLLISION: I TESTED WITH TOP-DOWN ONLY. var ColDown = ccbGetCollisionPointOfWorldWithLine (Pos.x, Pos.y+120, Pos.z, Pos.x, Pos.y-10, Pos.z); if (ColDown !=null) { Pos.y=ColDown.y+17.5;//set player 17.5 units up from ground(collisionpoint) print("Landed: GroundY="+ColDown.y +" PlayerY="+Pos.y); ccbSetSceneNodeProperty(this.Plr, "Position", Pos);//set it. ccbSetCopperCubeVariable ("OnGround", 1); ccbUnregisterOnFrameEvent(this.RegisteredFunction); }else{ print("Player jump active.."); ccbSetCopperCubeVariable ("OnGround", 0); } }[/code] What i did is make camera move with target.. so target wont move separate with camera, i didnt follow any formulas.[/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