# C2 Math question

Get help using Construct 2

### » Sat Feb 18, 2012 6:20 pm

Well it has worked perfectly for me in the past. Also, it is in the same wrong relative position regardless of the layer rotation.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,390

### » Sat Feb 18, 2012 6:47 pm

Here's a different way to look at it.
http://dl.dropbox.com/u/666516/randangleimagepoint.capx

As to the layer angle, remember the rotation is counter clockwise, since in essence you are rotating the view.
B
160
S
48
G
80
Posts: 7,234
Reputation: 61,496

### » Sat Feb 18, 2012 7:35 pm

@newt
That looks great! although why do you use numbers 4 and 16 instead of expressions of the size of the box? Basically to adapt this for my own purposes, I need to know how to adjust these constants.sqiddster2012-02-18 19:36:29
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,390

### » Sat Feb 18, 2012 7:43 pm

It just divides the rectangle up into the size of the second sprite.
Looks a little better imho, and its easier to get around the issue with hotspots on the second object.
So rectangle width divided by the second objects width/2 *the second objects width.
B
160
S
48
G
80
Posts: 7,234
Reputation: 61,496

### » Sat Feb 18, 2012 8:03 pm

By using a random angle and random distance the point ends up in a circle, the corners are never selected.

Here is how to have the point random out of the whole area.
http://dl.dropbox.com/u/5426011/examples%209/randpointonrect.capx
B
75
S
21
G
47
Posts: 4,663
Reputation: 36,691

### » Sat Feb 18, 2012 8:04 pm

OK, thanks, @newt.
The only problem is, the object within the rectangle has an altering width for me, and I suspect that this is what is stuffing it up.
What can I do if I want to consider the second object as a point entity?
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,390

### » Sat Feb 18, 2012 8:05 pm

randomAngledArea.capx
What I wrote earlier works fine for me...
Last edited by Yann on Sun Sep 14, 2014 9:35 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,336

### » Sat Feb 18, 2012 8:05 pm

oh, @r0j0hound, I missed that in Newt's example.
All right then, I'll go with yours, especially as it seems to allow an arbitrary width for the second object.

Many thanks all.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,390

### » Sat Feb 18, 2012 8:09 pm

Oh, shoot, @R0J0hound's won't work for me, I want to specify a position for the object to lerp to, not just make it appear there :(
Suppose I'll just use Yann's.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,390

Previous