≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
How would I do this?
Posted by:
(you are not logged in)
Enter the missing letter in: "In?ernational"
(you are not logged in)
Text:
[quote][b][/b] wrote: @Kierham, I am Sorry, however, the above code is correct but as it is written directly in the forum text box, I wrote in a fashion I don't usually write my codes into, I just tried the code myself and it didn't work for me either, It was positioning the sphere mesh to an undefined position. I rewrote the same code in visual studio in a different manner, and tested it, it works completely fine now. as you can see the code is the same as the above, it's just the writing manner that is different. Use the below code and you are good to go. Make sure that the physics engine is turned ON and your sphere mesh has a collide when moved or object moved by physics engine behavior attached to it. [code] var speed = 1; var physicsX = 0; var physicsY = 0; var physicsZ = 0; var sphere = ccbGetSceneNodeFromName("sphereMesh1"); var player = ccbGetSceneNodeFromName("player"); var playerPos = ccbGetSceneNodeProperty(player,"Position"); var spherePos = ccbGetSceneNodeProperty(sphere,"Position"); if (playerPos.x == spherePos.x){ physicsX = 0; } else if (playerPos.x >= spherePos.x){ physicsX = 1; } else if (playerPos.x <= spherePos.x){ physicsX = -1; } if (playerPos.y == spherePos.y){ physicsY = 0; } else if (playerPos.y >= spherePos.y){ physicsY = 1; } else if (playerPos.y <= spherePos.y){ physicsY = -1; } if (playerPos.z == spherePos.z){ physicsZ = 0; } else if (playerPos.z >= spherePos.z){ physicsZ = 1; } else if (playerPos.z <= spherePos.z){ physicsZ = -1; } ccbSetPhysicsVelocity(sphere, physicsX * speed ,physicsY * speed ,physicsZ * speed);[/code] Hope this is what you wanted to achieve cheers *holy*[/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