Welcome, Guest! Login | Register
Wrap around landscape ?
Info
Report
322 Posts

I am aware of infinite terrain, that's not what i am after, but more of a simulation of it using one terrain piece only.

I gots a math question in angelscript ( yes for 3drad )  how do i set a vector3.x  to its opposite value   I want to reposition a PCar to the landscapes opposite side when trying to drive off the edge.. this effectively will create a wrap around world ( a infinite landscape piece really )
Created on: 3 weeks ago
Edited on: 3 weeks ago
Info
Report
256 Posts

With the cars in 3D Rad in general you can't do a lot in terms of position manipulation. Cars break their velocity when having their position updated.

Anyway, what you're going for is the following...

void Main ()
{
	Vector3 currentPosition;
	iObjectLocation (OBJ_0, currentPosition);
	
	if (currentPosition.x > 1024)
	{
		currentPosition.x = -currentPosition.x;
		iObjectLocationSet (OBJ_0, currentPosition);
	}
}

This will make it so the car will go at the opposite side of the world on the X axis if it goes beyond 1024m. You might want to also set the opposite possibility (if the car goes negative -1024 to go back to positive).

But again, this might break, knowing how changing the location of a car breaks the car's velocity.

I can suggest you to try iObjectLocationReset() or iObjectPositionReset(), which will reset the velocity of the car (something to look out for), but they are at least stable and work in the expected way. You can try storing the velocity with iObjectVelocity() and then setting it after you call the position reset with iObjectVelocitySet()... But then you might also want to do the same for the rotation


Here's 3D Rad's script reference: https://classdev.net/page/thread/1HdOQq_s2GXWq4WP/3d-rad-script-reference
Created on: 3 weeks ago
Edited on: 3 weeks ago
Info
Report
322 Posts

Yup that's what i was looking for, it's basically what i had, but with a minor script error that you cleared up for me, Thankyou Power, also the velocity tip was needed too.

EDIT:
For anyone wondering what i was on about, here's the working project, save it as a .3dr to get 3drad to load it.

Also note, this basically works, but when you're near an edge and moving on an angle, you may still drive off the edge pretty quick if you don't recover your direction... play with it you'll see what i mean.
Created on: 3 weeks ago
Edited on: 3 weeks ago
Reply
Preview
Post
Or use the advanced reply form here...
Sponsored