LibGDX setToRotation canceling out position

I’m working on a 3d project in Libgdx. I’ve got a camera flying around in 3d space, being controlled with touch. Works great, moves forward and backward, strafes, full 360 look around with no gimbal lock.

But, I want my player to be able to see what they’re holding. So I’ve added a "hands" model instance, which I’ll change out depending on what is being held. I’ve positioned the model in front on the camera, which works fine.

But then whenever I try to call a transform.setToRotation, it sets the rotation, but moves the position back to 0,0,0. Does anyone know why this is happening? Here’s my camera update code:

public void updateCamera() {     // left right look     camDir.set(cam.direction);      cam.rotate(cam.up , deltaX);      // up down     tempVec.set(, deltaY);     cam.rotate(tempVec);         cam.update();      // move forward      cam.position.add(forwardTemp.set(cam.direction).scl(deltaForward));     cam.update();      // strafe     strafeTemp.set(cam.direction);     strafeTemp.rotate(cam.up, 90);       cam.position.add(strafeTemp.scl(deltaStrafe));     cam.update();          // move tool hands to match     handPos.set(cam.position);     handPos.add(forwardTemp.set(cam.direction).scl(1.5f));     handInst.transform.setToTranslation(handPos);      handInst.transform.setToRotation(cam.direction, Vector3.X);      } // end updateCamera 

Ponderate dijkstra relative to previous position

I use dijkstra in my rust game to find path to a destination. My game is in a square grid like this:


There is, for illustration, the Rust code which use dijkstra:

use crate::map::Map; use crate::physics::GridPoint; use pathfinding::prelude::dijkstra;  pub fn find_path(map: &Map, from: &GridPoint, to: &GridPoint) -> Option<Vec<GridPoint>> {     match dijkstra(from, |p| map.successors(p), |p| *p == *to) {         None => None,         Some(path) => Some(path.0),     } }  // ...  pub fn successors(&self, from: &GridPoint) -> Vec<(GridPoint, i32)> {         let mut successors = vec![];          for (mod_x, mod_y) in [             (-1, -1),             (0, -1),             (1, -1),             (-1, 0),             (0, 0),             (1, 0),             (-1, 1),             (0, 1),             (1, 1),         ]         .iter()         {             let new_x = from.x + mod_x;             let new_y = from.y + mod_y;              if new_x < 0 || new_y < 0 {                 continue;             }              if let Some(next_tile) = self.terrain.tiles.get(&(new_x as u32, new_y as u32)) {                 successors.push((GridPoint::new(new_x, new_y), next_tile.pedestrian_cost))             }         }          successors     } // ...  

And visualization of found path (white is found path, pink is goal):


The found path is not a direct line. I’m not surprised, because the weight of diagonal is the same as lateral. With what I understand with dijkstra is I can return successor with weight for a coordinate. But I can’t increase weight of diagonal/lateral according to previous position (ex: comming from West -> moving to Est will be less weight; maybe it is not the solution …).

How can I achieve that ? With another algorithm than dijkstra ?

2D Isometric Movement – Straight Line to Mouse Position

I’m developing a 2d isometric game on a engine made by myself (as a way to practice Java), however i’m stuck on what it seems to be a math problem, since I’m very bad at it. I can’t figure out to get the angle and change the X and Y velocity based on the angle.

I wish I could have some help on how to implement a 360 degree movement system based on Mouse Position, but the character should move in a straight line, based on the mouse angle relative to the center of the screen (where the player will be). The screen itself should work like a compass, and where the mouse clicks on it, the character should walk on said angle.

Example, my native resolution is 512×288. Center point is 256×144. So, If I click in in the coordinate of X = 256 and Y is 0~144, the character should walk on a perfect stright line upwards. If Y is 145~288, then, a perfect line downwards.

Any help is welcome!

enter image description here

Postgresql: sort by value position in array column, then by secondary order

I’m not quite sure what the best way to phrase this is…

So in my DB there is pillars text array which is basically an enum where providers ordered what values meant the most to their business, from most important to providing that value for their clients, to least important.

I’m using PostGIS to query providers in a specific area, and want to return providers ordered first by the pillar that a client selected they were looking for, then by closest location.

so if the pillars all have values ['a', 'b', 'c', 'd'], in any order depending on what providers selected, and the client selected pillar c

the results of the query would preferably return any/all providers that have pillar c at array index 0 first, ordered by distance to geopoint, then by providers that have pillar c at array index 1 second ordered by distance to client geopoint, then idx 2, then idx 3

I’m really only looking for the top 3 results in all cases, and providers with pillar c at idx 1 would only be needed if there were less than 3 results for index 0

Is this possible to pull off in a single query? or should I just run it with a where clause and check the results length until I have 3 results?

The pillars column is indexed with a gin index btw

How to spawn an object at a given position and angle?

Let’s say I have an enemy at position ( 150, 150 ) in my screen and I want it to shoot a bullet from its position at an angle of 315° (south-east if we’re cosidering a regular unit circle)…

I’ve tried doing something like this (pseudo-code):

bullet.xpos = enemy.xpos + (cos(315) * bullet.radius )

bullet.ypos = enemy.ypos + (sin(315) * bullet.radius )

The idea is to change the bullet’s position by increasing its radius…

However, the problem with this code is that the angle at wich the bullet gets placed it’s not really the one specified (315° in this case) because of course, the final result going into the bullets position gets influenced by the enemy’s position ( bullet.xpos = enemy.xpos… and bullet.ypos = enemy.ypos… ) but I still need to consider it since it will be the starting point for the bullet.

I might be overlooking something but I’m not sure how to actually do this… Thanks for taking the time

‘user’ is not valid at this position, expecting an identifier

CREATE TABLE ‘users’ ( ‘id’ int(11) unsigned NOT NULL AUTO_INCREMENT, ‘name’ varchar(75) NOT NULL, ‘password’ varchar(100) NOT NULL, ’email’ varchar(100) NOT NULL, PRIMARY KEY (‘id’), UNIQUE KEY ’email’ (’email’) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;


How to align prefab to a accurate position with the best practice?

I’m making a plumber game, I have a pump prefab, and pipe section prefab, which allows the user to connect the pipe during game, the pipe needs to be connected seamlessly during game, which means pipe prefab needs to be aligned in pixel level, please check below enter image description here

User needs to add more and more pipe to connect the with each other, pipe is fixed length prefab.I’ve got choices,

1.Is the pipe prefab instantiated during game play a good practice? Because it might have many pipe prefabs, if the pipe goes a long way to another position, than there will needs to be so many pipe prefabs, compared to have procedrually generated pipe mesh during runtime, then a long pipe will not have to be cut off to the same small pieces?Which is good way to adpot?

2.If I use the same pipe prefabs to fabricate the piping system, how to accurately connect each other in pixel level, I can make the whole piping system in blender, then cut the system into pieces as my prefabs, then import to Unity as my first choice, this can do pixel level connection, but it seems to have better choice solely solved pixel level connection in Unity?

3.If I do it by generating the mesh during game play, then it could be complex especially it is hard to make elbow pipe mesh during runtime, or could you please advise me of some known library or package can do the work?

How Can I Increase Breadcrumb Position Count (Starting From 2)?

In my wordpress functions.php, I have tried increasing locations position count in the breadcrumb from 2 and above in the foreach loop (while leaving out position 1 for Homepage).

Please how can I be able to achieve this? All suggestions are highly appreciated.

Below is what I tried

function zuluma_display_breadLocation($  pid) {     global $  zuluma_theme;     $  ad_country = '';     $  type = '';     $  type = $  zuluma_theme['cat_and_location'];     $  ad_country = wp_get_object_terms($  pid, array('ad_country'), array('orderby' => 'ASC'));     $  all_locations = array();     foreach ($  ad_country as $  ad_count) {         $  country_ads = get_term($  ad_count);         $  inc = 1;         $  item = array(             'term_id' => $  country_ads->term_id,             'location' => $  country_ads->name         );         $  all_locations[] = $  item;     }     $  location_html = '';     if (count($  all_locations) > 0) {         $  limit = count($  all_locations) - 1;         for ($  i = $  limit; $  i >= 0; $  i--) {             if ($  type == 'search') {                 $  sb_search_page = apply_filters('zuluma_language_page_id', $  zuluma_theme['sb_search_page']);                 $  location_html .= '<li itemprop="itemListElement" itemscope itemtype=""><a href="' . get_the_permalink($  sb_search_page) . '?country_id=' . $  all_locations[$  i]['term_id'] . '"><span itemprop="name">' . esc_html($  all_locations[$  i]['location']) . '</span></a><meta itemprop="position" content="$  inc++;" /></li>';             } else {                 $  location_html .= '<li><a href="' . get_term_link($  all_locations[$  i]['term_id']) . '">' . esc_html($  all_locations[$  i]['location']) . '</a></li>, ';             }         }     }     return rtrim($  location_html, ', '); } 

The below is what i got when i view the source code

<meta itemprop="position" content="$  inc++;" />