Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Idea for calculating position/angle?
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#1
Idea for calculating position/angle?

Okay, so I have this one scene where the player can use an item from different angles in order to get a slightly different result, but I'd like to improve this detection. Right now it uses 8 areas, 4 facing each cardinal direction and 4 in between those. I named the areas with _n_, _ne_, _sw_ etc. I have a UseItem callback on all areas calling the same event, using StringContains on asEntity to detect which area it is, then execute slightly different code for the results. It all works just like I want it, but it CAN be a little inaccurate at times.

Spoiler below!
[Image: k1LS3P8.png]

To explain a bit further what is going on, you use this item from different angles to place the item at the angle you used it from. If you use the item on the _nw_ area, the item will spawn facing the north west. The area in the middle (inactive in the pic) is used to pick up the item again after placing it, by interacting with it. The area on top is just to block the player from using it on the area on the opposite side of the column, by touching the edge of that area. It works to prevent that, but it doesn't prevent using the item on the edge of the side areas.

Basically, if you're standing on the north side, I want the item to appear facing north, but if you use the item at the very edge, you might be able to hit the west or east areas instead, and thus the item will face that direction. I don't want that.

Sooooo, to my question (finally). Is there a better way to detect the players position in relation to an object? The GetEntitiesCollide script does not support Player.

If I can't get a hold of a better way than what I have then I'll just go with it, because it works fairly well, but not perfectly.

Any suggestions are very much appreciated <3

05-22-2014, 04:51 PM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#2
RE: Idea for calculating position/angle?

Mmmh What if you set the areas active only when the player looks at them?
So only the area he's looking at will accept the item.

05-22-2014, 08:51 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#3
RE: Idea for calculating position/angle?

That still wouldn't make a difference, because if he looks at the edge, the game will assume he's standing on that side. I thought about something similar, but since you need to look at an area to use an item on it, all areas would be active anyway.

But maybe if I change the size of them or something...

05-23-2014, 01:35 AM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#4
RE: Idea for calculating position/angle?

Yeap. What is all this coding for? You're working on something original?

05-23-2014, 02:45 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#5
RE: Idea for calculating position/angle?

I guess you could say that. I have a little Youtube experimental series where I take ideas and try to implement them, though I have a certain line I want to follow. This exact situation is present in a puzzle I'm making involving guiding a beam of light using mirrors, lenses (for colors), splitters and other contraptions. The reason I need different angles is because the player should be able to place these objects differently, since each check point can have 4 different results based on angle of each object.

Here's a video showing it more in action. Perhaps it can help explain the issue better. Skip to 6:00.
[video=youtube]http://youtu.be/yc48CqOc-qU?t=6m[/video]

(This post was last modified: 05-23-2014, 08:27 AM by Mudbill.)
05-23-2014, 08:27 AM
Find
DnALANGE Offline
Banned

Posts: 1,549
Threads: 73
Joined: Jan 2012
#6
RE: Idea for calculating position/angle?

I saw the vid Mudbill...
I gtg soon, so try to make this short..
-
Istn it possible to make those area's around it.
And try to make it like this?
---
IF player is standing in area North -> disable all other area's on top of the pedestal.
IF player goes OUT the area, turn all the area's on.
SO standing in NORTH ( deactivate south west etc etc.. but leave NORTH as it is for adding the mirror there.
Might work pritty good i guess..
-----
PHP Code: (Select All)
AddEntityCollideCallback("Player""NORTH_Area""ActivateNorthAndDeactivateothers"false0); 

PHP Code: (Select All)
void ActivateNorthAndDeactivateothers(string &in asParentstring &in asChildint alState)
{
if(
alState == 1)//When INSIDE the area
{
SetEntityActive("NorthPedastal"true);//I dont know the real names you fill the in yourself.

SetEntityActive("SouthPedastal"false);
SetEntityActive("SouthEastPedastal"false);
SetEntityActive("SouthWestPedastal"false);
SetEntityActive("WestPedastal"false);
SetEntityActive("NorthwestPedastal"false);
SetEntityActive("NortheastPedastal"false);//Etc etc the area's you have in your editor.
}

if(
alState == -1)//When leaving the area
{
//Then REVERSE all of the area's when OUT of the NORTH area.
}

---
The only annoying this is you need to make 8 of these scripts...
BUT, you can sorta copy paste them and change some small area's.
(This post was last modified: 05-23-2014, 11:17 AM by DnALANGE.)
05-23-2014, 11:05 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#7
RE: Idea for calculating position/angle?

That's an idea. I first thought it was like what I had already tried, but I don't think I disabled other areas next to. It might work. Suppose I'll give it a try later.

05-23-2014, 11:11 AM
Find
DnALANGE Offline
Banned

Posts: 1,549
Threads: 73
Joined: Jan 2012
#8
RE: Idea for calculating position/angle?

(05-23-2014, 11:11 AM)Mudbill Wrote: That's an idea. I first thought it was like what I had already tried, but I don't think I disabled other areas next to. It might work. Suppose I'll give it a try later.

Oki Mudbill.
IF this isnt working ( i guess it should work great .. have it on premonition sorta the same )
Then we will find another solution for you.
(This post was last modified: 05-23-2014, 11:16 AM by DnALANGE.)
05-23-2014, 11:15 AM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#9
RE: Idea for calculating position/angle?

I see. I would let the player turn the mirror himself.
You place the mirror, then you start turning it by clicking on it.
It could turn about 45° each time.

05-23-2014, 02:07 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#10
RE: Idea for calculating position/angle?

I had that idea too, but how would I pick it back up? The player needs to be able to remove the mirror as well, and if clicking on it rotates it, I'd need something else for picking it up and I think that could be confusing.

Edit:
Alright, I'm re-writing the whole thing and I think I might be onto something that could work. I do have one question, almost off-topic. You miiight have noticed that I mentioned in the video that the other mirror item wasn't working due to its name. Does anyone know if AddUseItemCallback does NOT support the use of asterisk? Using "ItemMirror_*" in the item string does not work, but it doesn't say anything on the documentation that asterisk isn't supported. Oh, and I also have it inside a for-loop, and for some reason, using "ItemMirror_"+x did not work either, which is very odd to me. Well, it kinda works, but not quite. The item named ItemMirror_2 seemed to react, but _1 and _3 does not.

(This post was last modified: 05-23-2014, 06:37 PM by Mudbill.)
05-23-2014, 03:29 PM
Find




Users browsing this thread: 1 Guest(s)