How do you limit how far the mouse can turn/rotate an object?

If it’s even possible beyond using IK constraints.
I’m trying to limit a cube tracking a crosshair and instead of it rotating freely,
I want it to only turn 30° going left and right.
Help would be greatly appreciated.

MouseOverTarget.blend (598.3 KB)

mathutils has a lot of angle functions builtin. most positions and orientations are mathutils classes.

use the math module to convert radians to degrees.

when i get to my pc ill whip up something. if someone doesnt beat me to it :smile:

import math

def rot(cont):
    own = cont.owner
    ori = own.worldOrientation.to_euler()

    if math.degrees(ori.z) < 30 and math.degrees(ori.z) > -30:
        own.color = [1,1,1,1]
        #add rotation code here or activate the brick
    else:
        own.color = [1,0,0,1]
        #stop rotation code here or deactivate the brick

maybe the better solution is to limit where the cursor goes? (in turn limiting rotation). not sure what this is going to be used for.

also, you have aligning in the code and in the logic bricks?

I was expiramenting with stuff to see what would stick.
The logic bricks were the expirament.
It failed.

along what reference do you want the angles to be centered around?

i fixed alot of oddities. the z offset doesnt seem to work very well. i recommend an overlay scene. do you want to keep the depth effect?

MouseOverTarget.blend (605.5 KB)

I was attempting to do something similar to this minus the IK bones:
IkTractToPlacedByMouse.blend (450.7 KB)

so you want it centered around the direction that the cube is facing? that i can do.

Yes, exactly.
I want it to face in the direction the player is facing.
I also don’t want an overlay.
My experience with it limits it’s interaction with the environment unless python is involved.
What’s wrong with z offset?
It seems to do what I want best.

Wait!
Damn it!
Forgot to add my movement script to the file.
Sorry :confused:
MouseOverTarget.blend (628.4 KB)

im working on optimizing your movement script to use mathutils. shouldnt affect the function at all.

i also got the overlay scene working with a custom mouse over. working on the limiter now.

Here’s the master project so that you have a better understanding of the script.
2.5d camera3 final.blend (697.5 KB)

MouseOverTarget_Overlay.blend (668.5 KB)

ill look at this more later. but here is a working overlay scene. im convinced as of now that limiting isnt the best solution for this setup.

ok, at this point ive officially derailed this question. sorry about that. but i just couldnt figure out the intended mechanic for limiting when matched with this style of game. this would be way easier if it was a standard 3rd person over-the-shoulder or even fps.

anyway, i got so frustrated with the crazy camera that i completely over hauled it to be more predictable and less complex. now that i can test the game without going nuts, ill merge this with the screen space targeting system.

if the character is always looking to the crosshair, then a limit on the X axis (pitch) could be a nice thing. but still possibly unpredictable if you try and attack a point on the screen thats out of the limit range. perhaps setting the crosshair to a gray color to show you cant reach that point.

its just a start, but i want to know if im barking up the right tree. it works by raycasting to the ground to find camera control objects. it supports “PIVOT”, which points the camera at a center, “BEND” which points away from pivot, and anything else means align to the Y axis of object. it would be easy to add a zoom property, custom pivot target, or camera pitch.

2.5d camera3 dae.blend (727.4 KB)

EDIT:
heres version 2. now with zoom, overlay crosshair, and the start of character switching.
2.5d camera3 final dae v2.blend (804.3 KB)

I’m really sorry that it frustrated you to where you went nuts.
I feel really bad if I’m being a burden with this.
I really wish my ideas weren’t too complex to work with on my end as well but, I will definitely compensate monetarily for help with a quality game. If you want to be compensated. I haven’t heard back from another guy yet if he wanted to be. I’m a man of my word and I really want to share my ideas with the community if nothing else.

So, I can’t retain my long shot, top-down nor low angle camera angles or assign a tile to point the camera at X, -X, Y, -Y anymore?
I was really hoping to keep those to allow low spec systems to play my game by not having to load every angle (like 3rd and 1st person games as a cost for free roaming cams) with details and be able to hide stuff. While also being able to show large areas of detail and environmental focal points (nukes, building collapse, etc.). As well as cheat with the illusion of high detail with depth of field.
I’m perfectly fine with your rig (far more stable than mine) but, not as flexible as mine.

Maybe Blender Foundation might reconsider bringing back BGE or implement it into Eevee or make it stand alone if they see what it’s capable of. One can dream.

sorry, i can be a bit dramatic :grin:. you arent being a burden to me at all! in fact, i rather enjoy a good rabbit hole to get lost in. no compensation or credit needed, i work for the embetterment of the bge community (and my own learning).

its in my experience that shaders, especially speculars, are the most devestating to low end. i slapped my massive high end optimized game into an intel hd 630 and i got pretty good fps when i set the shader quality to shadeless texture and ditched anisotropic and antialiasing. like 30-40 in the parts that my gtx 970 has to think about.

as far as camera stuff goes, i can try and add anything you want. i guess i didnt know that stuff was there at all… i did think about a top down for things like the 4 way intersection. ill see what i can do.

btw, i tried having the character always point at the cursor, and it felt kinda weird. game mechanics are a real pain.

Oh, so you know, for possible reference reasons I was heavily inspired by this game for the weapons system and some of the camera angles.

Nier: Automata and Mortal Kombat Mythologies: Sub-Zero inspired the rest of the camera angles

features i can do no problem. but i think this the time to consider level design.

the shadow complex (and mk) was plain and simple side scroller. the demo file you have isnt a side scroller. honestly im not sure whats called, platformer maybe? not in a bad way, its just different, with a different set of rules.

the point is, you need to establish constraints and constants so gameplay is smooth and predicable. creating at least one really fleshed out level would go a long way to know how to optimize code. even if its a simple drawing of what should happen where.

EDIT:
i been watching Nier: Automata gameplay, and it seems this is more like what you are after. its got a little bit of everything all smashed together.

Yeah, Nier and Mostly Jackie Chan Stuntmaster (as far as a constant closer to 2.5d maybe even 2.7d ^_^) are what I’m looking for.

Oh, I also need the weird camera angles for insides of some buildings that are bigger on the inside, intersecting hallways that don’t intersect, portals and the contrast between points.

The example project that I gave you is only a test level for expiramenting with all of the variables in the game. It isn’t how the final game will be like. It’s an obstacle course if you will to see what works and what doesn’t.

All of the mechanics for my game:
The Cameras:

-A minor Point"n"click portion that will be the only first person mouse look camera scenes in the game.
There will be a few of them when exploring interiors.
Unfortunately, I haven’t made this yet.

-Then, I have a character switch system (scripted with .blend).
I just need a camera transition between the two characters.
My Character switch.blend (530.6 KB)

-I using two projects for double tap button functions (run, vertical wall run, fall rolling, crouching and commando crawl).
http://www.mediafire.com/file/78ak9lwftd24b83/Runner_5.0.blend/file

-I have a command system (script and .blend) that tells partters to stay or follow.
I just need to make it so I can just go up to the character and press a button for a command.
squadai.blend (700.5 KB)

-I’m using an Echolocation script for the second character in my game only.
Echolocation multicolor.blend (894.0 KB)

-Grappling hook mechanic that I’ll be using for many things.
Including Ziplines.
Grapple2.blend (518.6 KB)

-Character Ledge Boost was something I’ll be working on when I complete the characters.

-I might need help with companion character mimicking the lead (interchangeable). I tried triggers but, it always made both jump upon hitting it.

-I have a countdown timer.
countdown_timer.blend (573.8 KB)

-I have a Shake Cam for Earthquakes and explosions.
camera shake.blend (481.3 KB)

-You can drive cars too.
http://www.mediafire.com/file/uqdauj9utaprrmi/3rd_person_rig13.4.blend/file

-Parkour plays a huge part in the game. Haven’t started this yet. I do have a project that I’m working with though.
http://www.mediafire.com/file/uqdauj9utaprrmi/3rd_person_rig13.4.blend/file

-Ladders
BGE_Ladder6.blend (4.1 MB)

-Inventory and Weapon select and pick up and scene carry.
PickUpSystemX.blend (550.0 KB)

-Slomotion.
There will also be time stop as well.
It will be like swimming.
slow motion.blend (1.7 MB)

-Swimming and Flying
swimming.blend (5.0 MB)

-checkpoints
check_point01.blend (604.3 KB)

-Load and Save
save_and_load 4.3.blend (587.3 KB)

Yeah, it’s a very complex game and took me all day to remember and list everything aside from non in-game mechanics(menus, etc.).
My game will cover Dimensional Anomalies, Time Travel (time jumps mainly), Future tech and tech so exotic that it appears supernatural to the main characters who are from the present.

I see you’re using the 3rd person template, (3rd person rig 13.4) I’ve been studying the code in that template for years. And it still confuses me LOL. The person who made this is a genius, IMHO.
I’m trying to get the animationhelper.py to work with my BVH animations, ATM.

Anyway . . .

Looks like a great concept. Can’t wait to play it.