Point-at problems

Hi guys, I’m back with YET another help request.

For my new game, Vehicle Battlefield re-make, I’m trying to add full controller support, but it REALLY isn’t working.
The problem isn’t actually with the controller behaviors, it’s with the point-at behavior. I have a set of globals (X & Y) that the turret on the tank is supposed to point at, but the glabals are being annoying and I can’t seem to find the problem. Here’s the code:

This code clearly doesn’t make the gun point towards the cursor object.

Does anyone know why? I think I might’ve made a help request on the same topic a while back, but I don’t quite remember how it was fixed, so here I am again.


1 Like

Check the turret forward direction

1 Like

The turret doesn’t have physics enabled.

1 Like

Just enable it, turn the forward direction to up I think, then disable the physics

1 Like

you need to subtract camera x and y

1 Like

The camera is in the player, and the gun is attached to the player. What would I need the X and Y of the camera for?

1 Like

It’s not the foreword direction.

1 Like

can you send me the code for the point at thing then please? i’ll try to have a look at it.

1 Like

subtract the camera x and y from the positions of the mouse x and y
put mouse move on screen


I think forward direction is on the right.

Is mousemove set to the game layer?

1 Like

The cursor is in the User Interface.
The issue is improperly showcased and the description doesn’t clearly describe what’s actually happening. So the cursor does work perfectly fine, however it stops working when controller is connected because the Cursor X/Y Globals are different than what the MouseMove behavior is actually outputting. You can very easily see this just by running the code as the game is running.

I’m not using a controller however, so that other part of the code you showed isn’t activated. I’m just assuming this is the issue.

So the issues are;

  1. The Globals aren’t the same as the X/Y from the MouseMove. I have no idea what code is setting the Globals, but that should be a very simple fix.

  2. Why do you even care about the Cursor if you’re using controller? It makes absolutely no sense to have any code for that.
    The turret should be controlled by R-Stick, not by the cursor.
    Finding that angle is very easy to do, just use the bundle JR made for his controller example. It’s simple, easy, and works.

1 Like

The cursor is where the player aims, it’s just to show, I thought it would be the best way to show where you’re going to shoot.

No, why would that matter?

I use the left-stick for aiming the gun and the right for movement.

Game layer matters alot. For example, if the cursor were to leave the screen, when returned the cursor would glitch.

Ok, I’ll keep this in mind. I only have three days to fix the bugs!

Yeah, so I’m saying you have no issue.
Everything is working as it’s meant to, unless you’re saying with controller it’s not pointing towards where you angle, but I didn’t see any code for that.

1 Like

It’s in the gun. I need the gun to point towards the reticle when the player isn’t using a mouse.

Ok you didn’t describe your problem well enough at all before, I could not tell at all that you’re just trying to get controller to aim. That’s what you’re trying to do, right?

1 Like

Yep. I have the left stick move the reticle and the gun needs to point towards it. I have two ways to do this in mind:
1: Have the reticle control the gun.
2: Have the gun control the reticle.

I tried to make the first idea, but it isn’t working, that’s why I made this help request. Sorry for not explaining it like this earlier.

The reason it wasn’t working is because the game Cursor is basically on Screen Coords, while the MouseMove is using Game Coords.

All you need to do to fix it is get the Camera X/Y

Then use that for a simple equation.

1 Like