playMaker

Author Topic: Constrain Movement/Strategy for a Target Reticule [SOLVED]  (Read 1322 times)

MarkD

  • Full Member
  • ***
  • Posts: 113
Constrain Movement/Strategy for a Target Reticule [SOLVED]
« on: June 19, 2020, 11:38:44 AM »
Hey folks,

I could use some advice on either how to constrain movement of an object OR a strategy for how to do what I'm attempting.

I'm making a side scrolling game and I want the player to activate a target reticule that they can move around the screen to "target" things they want to fire upon. 

My requirements are:

- Constrain the movement of that reticule on the X and Y. 
- More specifically, have separate constraints for High value Y and Low value Y (I dont want the reticule to go under the ground).
- I want the reticule to move freely through/over objects with collision
- Works with a game controller

So my current plan is to use a 3d object in world that the player moves around with a controller.  I'm getting the Axis vector X/Y and setting the velocity on the 2d object.

This will easily allow me to move through collision objects while still giving me the ability to know if I'm over an acceptable target (using trigger volumes).  BUT I can't figure out how to constrain the movement in 4 directions (Left, Right, Up, and Down).

I've tried using a character controller, but that has the problem of obeying collision rules.

So what do you all thing?  Any advice about how you might tackle this challenge?
« Last Edit: June 23, 2020, 10:55:05 AM by MarkD »

MarkD

  • Full Member
  • ***
  • Posts: 113
Re: Constrain Movement/Strategy for a Target Reticule
« Reply #1 on: June 19, 2020, 08:08:03 PM »
Still interested in hearing folks opinions, but I found a method to do what I need using my 3d target reticule.

I created a collision volume around my player and put those objects on a unique collision layer.  Using the Collision Matrix, I made it so that my reticule won't collide with anything BUT the unique collision layer.

It seems like it'll do the trick, but I'd be very curious to hear if anyone has any other ideas!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Constrain Movement/Strategy for a Target Reticule
« Reply #2 on: June 20, 2020, 01:40:34 PM »
Hi.
I would probably use some float clamps.

If the reachable area is rectangle that should be fairly easy.

if rounded maybe a bit more complex.

MarkD

  • Full Member
  • ***
  • Posts: 113
Re: Constrain Movement/Strategy for a Target Reticule
« Reply #3 on: June 20, 2020, 02:12:05 PM »
Well, what exactly would you clamp?  I tried clamping the x and y from a vector3 but it did nothing for me.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Constrain Movement/Strategy for a Target Reticule
« Reply #4 on: June 20, 2020, 07:51:59 PM »
Hi.
How are you moving the reticle?

I would have the reticle set as a child to the player, then move the reticle in 'Local Space'
and use the float clamp when setting the position


MarkD

  • Full Member
  • ***
  • Posts: 113
Re: Constrain Movement/Strategy for a Target Reticule
« Reply #5 on: June 21, 2020, 11:47:05 AM »
Heya - yep, I've got the reticule parented to my player object. 

In my current setup, to move the reticule, I'm doing this:

- Get Axis Vector XY and store that Vector3
- Controller Move using that Vector3 variable

Previously I tried using set position based on that same Get Axis Vector3 var.  I tried using a get XYZ of a vector 3 and clamping those floats and then using Set position XYZ.  I could totally still move the reticule around, but the clamps didn't seem to do anything.  Also, anytime I let go on my controller stick, the reticule would snap back to 0,0 which wasn't ideal.

Does that make sense?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Constrain Movement/Strategy for a Target Reticule
« Reply #6 on: June 22, 2020, 01:41:44 PM »
Hi.
if you used float clamps before setting position it should work.
Also going back to 0 should not happen due to clamp.




MarkD

  • Full Member
  • ***
  • Posts: 113
Re: Constrain Movement/Strategy for a Target Reticule
« Reply #7 on: June 23, 2020, 10:54:46 AM »
Ahh excellent. This does exactly what I'm looking for without having to use clumsy collision.

Thank you!