Welcome to the Mobile & Console Development area of the site. Some reading before you post:
The Forum FAQ has answers to many beginner questions, including a listing of cross-platform engines and libraries to help begin developing on various devices.
Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 13 March 2012 - 11:09 AM
Posted 13 March 2012 - 11:10 AM
Posted 13 March 2012 - 05:03 PM
Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.
Also check out my personal website at bryanwagstaff.com, where I occasionally write about assorted stuff.
Posted 14 March 2012 - 10:38 AM
Posted 15 March 2012 - 11:59 AM
double theta = Math.atan2(nextY - posY, nextX - posX); //calculate the angle of the next coordinate relative to the current position velX = magnitude*Math.cos(theta); //calculate the velocity of X given using the angle of theta and magnitude of the total velocity velY = magnitude*Math.sin(theta); //calculate the velocity of Y given using the angle of theta and magnitude of the total velocity currX+=velX*(timeElapsed); //add the velocity to the currentX currY+=velY*(timeElapsed); //add the velocity to the currentY
Posted 15 March 2012 - 01:53 PM
Sorry I think I was a bit unclear about my intentions. My plane has a velX and velY value that is added to the position to move it. When a path is created I'm having an issue moving the plane along to the next point. I tried :
double theta = Math.atan2(pathPoints.firstElement().y-posY, pathPoints.firstElement().x - posX);
velX=(float) (magnitude * Math.sin(theta));
velY=(float) (magnitude * Math.cos(theta));
but this results in the plane moving in a straight line away from the point, in the opposite direction. I also tried doing posY-velY but this resulted in the plane flying in a circle. What am I doing wrong?
// Unnormalized direction vector to move to. velX = pathPoints.firstElement().x - posX; velY = pathPoints.firstElement().y - posY; float length = velX*velX + velY*velY; float desiredVelocity = x; if (length <= desiredVelocity*desiredVelocity) { // distance to target is shorter than our velocity. We have arrived to our target, what to do? // Immediately snap to target, or take next waypoint instead? return; } // Scale the velocity to the desired length. length = 1.0f / Sqrt(length); velX *= length * desiredVelocity; velY *= length * desiredVelocity;
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.