Tag Info

Hot answers tagged

7

Ok, that's awkward. My last edit revealed the answer to my problem (that I've been struggling with all day): QGraphicsView casts the camera x/y position to integers... This is the solution: void SceneView::centerOn(const QPointF &pos) { if (mScene) { mScene->setX(int(-(pos.x() - width() / 2))); mScene->setY(int(-(pos.y() - ...


2

Here is a simplified example of how you could implement a check to see if your gameObject is grounded or not. It is not perfect, but should probably work for your situation: bool Grounded; void OnCollisionStay2D(Collision2D collider) { CheckIfGrounded (); } void OnCollisionExit2D(Collision2D collider) { Grounded = false; } private void ...


2

Scalar multiplication. Assuming the plane moves at constant speed, you can determine how far along it is (0 meaning at departure_point and 1 meaning at arrival_point) progress = distance / speed * time_elapsed You can also compute a vector (x,y) representing the translation of the airplane from its departure point to its arrival point, by subtracting one ...


2

Based on my memories and for example this: While it's difficult to understand the complicated ANDs and ORs, it seems clear that you forgot to check for the jumpButton being pressed after the other buttons. With leftButton and rightButton, you have Gdx.input.isTouched(0) as well as Gdx.input.isTouched(1) (with OR inbetween them, so I take that as you're ...


1

To determine the cone you should create some variables like AttackLength, FieldOfViewAngke and get enemy component to determine enemy position lookDirection = enemyPosition - player.transform.position; lookDirection.y = 0; attackDirection = Vector3.zero; float angle = Vector3.Angle(lookDirection, transform.forward); if (Physics.Raycast(enemyPosition, ...


1

I had the reciprocal of what I should have been using. The math.h class's sin and cos function want the arguments in radians and m_ShipAngle is in Degrees. I was doing movementX = m_ShipVel * (cos(m_ShipAngle * 180 / PI)); movementY = m_ShipVel * (sin(m_ShipAngle * 180 / PI)); When I should have been doing: movementX = m_ShipVel * ...


1

Use physics instead to move your object like rigidbody.AddForce(Vector3). Using physics will solve your problem with bouncing.


1

You can use Vector3.Lerp(transform.position, WAYPOINT POS, Time.deltaTime) for smooth movement from one point to another.



Only top voted, non community-wiki answers of a minimum length are eligible