I’ve gotten myself in a bit deep with Unity already, and I’m only in the second semester of a Computer Games Design course. Because of that, to continue with my idea, I need a hand from someone who’s experienced with coding in Unity and also a dab hand at maths.
One of the specific points of the brief in this topic is that there must be some form of projectile existing within the game’s structure to demonstrate the ability to use rigidbody components. While this is a simple enough thing to implement in, say, a FPS styled game where you would only have to click a button and the physics engine would do the work. I’ve decided - with the lecturer’s permission - to bend the rules a bit, and am doing a isometric styled RTS/RTT game al la World in Conflict - which causes some issues with projectiles. While I can simply code in pressing a button and launching a projectile, I need to be able to click a location, and the game calculate the power needed to throw the grenade at a 45 degree angle.
I know I need the angle, power and target of the grenade in order to create the formulae to do this. I’ve got the angle - 45 degrees - and I’ve got the target - the point in which a raycast from the mouse location intersects the terrain. My problem is how to get the relation between the target and the angle to determine the power required to get the location. Does anyone know the formulae required for this, and how I’d write a script to implement it?