Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,089 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Confining movement to a sphere? #176161
01/03/08 09:49
01/03/08 09:49
Joined: Jun 2001
Posts: 385
Eastern Washington State
Z
Zio Offline OP
Senior Member
Zio  Offline OP
Senior Member
Z

Joined: Jun 2001
Posts: 385
Eastern Washington State
Right now I'm using a super basic movement script to move an entity around and I'm limiting the entities position with clamp()'s.

This gives the effect of the entity being confined to a cube. It works, but, I need the boundary to be a sphere, not a cube. Kind of like moving an entity that is chained to a post, it shouldn't be able to move farther away than X in any direction.

I'm not quite sure how to do that! I could use some help

Last edited by Zio; 01/03/08 09:49.
Re: Confining movement to a sphere? [Re: Zio] #176162
01/25/08 04:50
01/25/08 04:50
Joined: Jul 2006
Posts: 503
Australia
A
adoado Offline

User
adoado  Offline

User
A

Joined: Jul 2006
Posts: 503
Australia
Maybe use vec_dist.

Code:

var chained_to_post_location[3];
var max_distance = 100;

vec_set(chained_to_post_location, vector(0,0,0));

if (vec_dist(chained_to_post_location, player.x) > max_distance)
{
AllowedToMoveForward = 0;
}
else
{
AllowedToMoveForward = 1;




This makes it that if the player is greater than a certain value away from a location, you can simply prohibit forward movement.

Just off the top of my head, so its not tested


Visit our development blog: http://yellloh.com
Re: Confining movement to a sphere? [Re: adoado] #176163
01/27/08 12:56
01/27/08 12:56
Joined: Nov 2004
Posts: 862
Australia
DavidLancaster Offline
User
DavidLancaster  Offline
User

Joined: Nov 2004
Posts: 862
Australia
Possibly, put an invisible hollow cylinder around the player or if the player steps outside the boundaries of the sphere (check using vec_dist), before the wait instruction move the entity to the boundary by moving it to the border of the cylinder in the direction it is from it's centre. Hope that makes sense.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1