≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
How to get angle between 2 object
Posted by:
(you are not logged in)
Enter the missing letter in: "Internat?onal"
(you are not logged in)
Text:
[quote][b][/b] wrote: I think you just need a normilized angle between camera and your enemy rotations. So you get rotations first: var camRot = ccbSetSceneNodeProperty(camNode, 'Rotation'); var enemyRot = ccbSetSceneNodeProperty(enemyNode, 'Rotation'); then calculate the difference. since y axis is up you only need it: var diff = enemyRot.y - camRot.y; //normilize, so it's always between 0-359 degress: diff = (diff % 360 + 360) % 360; //now you pick an animation based on this diff value: if (diff >= 330 || diff < 30) { // .. forward } if (diff >= 30 || diff < 60 ) { //.. right-forward } and i.e.[/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