Wednesday, July 20, 2016

P3D2



Made rough draft 2 of the design doc and fleshed out the setting.  Drew a bunch of stuff too but too lazy to scan them in for now.

Swapped out cube for Rynn's block-in model.  Decided to use velocity to determine her facing, but switching her movement to velocity made her movements really floaty.  Ended up forcing her to stop when no movement keys are pressed.  There is probably a better way and I spent a funny amount of time to get to the clunky solution :\

I eventually want her upper body to rotate towards player mouse.  Using a hacky indicator for now.  Still pretty sure it's not working correctly, but at least I learned how to use raycast to determine the world position of the mouse.  I understand zero amount of maths on this and will have to learn math again for sure.

Code Notes:

Seems like the new API convention or something (??) made a lot of short-hands like "Rigidbody" or "camera" not work.  Rather, "GetComponent<Rigidbody>()"seems to be the way to go.

transform.rotation = Quaternion.RotateTowards (transform.rotation, Quaternion.LookRotation (new Vector3 (transform.GetComponent<Rigidbody> ().velocity.x, 0, transform.GetComponent<Rigidbody> ().velocity.z)), Time.deltaTime * rotateSpeed);

Must look into Quaternion-related stuff.  Need to relearn geometry as well.

RaycastHit hit;
Ray ray = mainCamera.GetComponent<Camera>().ScreenPointToRay(Input.mousePosition);
Physics.Raycast(ray, out hit);
Vector3 lookTarget = hit.point;
lookTarget.y = hit.point.y + gameObject.transform.position.y;
gameObject.transform.LookAt (lookTarget);


I'm still thrown off by the grammar of this raycasting endeavor.  Also, the LookAt seems pretty gimpy and I don't know how to control or change the "forward axis".  Might not be very usable if I want to use this to define shooting direction.  Found some complicated math stuff that again has to do with angles.  Geometry.

Next Steps:
  • Get the pointer to rotate towards mouse direction at a fixed speed
  • Spawn projectiles flying along the "front" direction of the pointer on mouse click (not necessarily towards mouse)
  • Make some environment assets that can be placed
  • Separate out Rynn's upper body so it can rotate properly instead of the pointer


No comments:

Post a Comment