Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destination Arrow #6

Open
mgshadow opened this issue Apr 18, 2020 · 1 comment
Open

Destination Arrow #6

mgshadow opened this issue Apr 18, 2020 · 1 comment
Labels
core Core feature

Comments

@mgshadow
Copy link
Collaborator

create a arrow which points to a certain location

@mgshadow
Copy link
Collaborator Author

function updateArrow(player:Object, targetName:String, arrowName:String)
{
	updateArrowInt(player, iron.Scene.active.getChild(targetName), iron.Scene.active.getChild(arrowName));
}

function updateArrowInt(player:Object, target:Object, arrow:Object)
{		
	var direction = target.transform.world.getLoc().sub(player.transform.world.getLoc());		
	
	var angleZ= Math.atan(direction.y/direction.x) + Math.PI/2;
	if (direction.x < 0)
	 {
	 angleZ += Math.PI;
	 }
	
	arrow.transform.setRotation(Math.PI/2, 0, angleZ);
	
	return;
}

@tong tong added the core Core feature label Apr 18, 2020
@tong tong changed the title Desination Arrow Destination Arrow Apr 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core feature
Projects
None yet
Development

No branches or pull requests

2 participants