Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
Press E to do something

karmacomposer
Registered User
Quote
2022-12-08 06:07:39

How would I program an action (press 'E') to do something?

I want the 3rd person player to trigger something when they are on a object or plane.

In this case, in front of a house, I want the player to stand on a plane. I issue the behavior "on proximity do something" and set it all up the way I want. When the player object is on the plane, I want to to show text on screen saying "Press 'E' to enter" and when they press "E" while on the plane, it switches to a new scene of the interior of the home object.

How would I accomplish this?

Thank you.

Mike


sven
Registered User
Quote
2022-12-08 09:48:53

The hard way to do it is without scripting.
Create variable at_house_entrance=0
Now if player on that plane on proximity enters area set variable to 1.. now on proximity leaves the area set variable to 0.. now if key pressed E and variable =1 then switch scene.

That means if E pressed and variable =0 nothing happens but if variable =1 scene switch happens...

So its the usage setorchange variable and if statement.

And this way you can make many entrances and use one keypressed behaviour but multiple if statements under it.

Also ic you switch scene you may want to set variable -1 so it wont be called multiple times (on some situations )


karmacomposer
Registered User
Quote
2022-12-08 14:33:13

Thank you for that. I am actually a database programmer, but I have not scripted for Coppercube. How would I write a script to take care of this? How is a script fired off?

Using the above, how would I show the text "ENTER HOME" or something like that so then they press the action key ("E") to enter it?

Thank you. The above is a bit confusing due to its laundry list sequential way of operating.


sven
Registered User
Quote
2022-12-08 15:07:46

You can create 2d overlay and set and change its text ..
So if enters area set text..
Also you can set overlay visible / invisible.

With programming there is many ways how to solve this kind of stuff but its project specific so cant tell you how its the right way to do..

If you already know programming then you will find out the ways how to solve things like this..
I recommend you to read coppercube scripting reference.

BUT if you are not planning to do big project then i wouldnt use scripting at all but use visual script.


samgrady
Registered User
Quote
2022-12-12 03:22:55

you talk about something like this?
🔎︎



edwin123
Registered User
Quote
2022-12-13 00:26:40

wrote:
you talk about something like this?
🔎︎




can i know how you did it?


samgrady
Registered User
Quote
2022-12-13 08:30:09

this will return true if your player ("playerName") enter on object ("objectName") in range of "distance", after you can do something like enter to another room or change scene by press some key

function enter_on(playerName, objectName, distance){
var p_pos = ccbGetSceneNodeProperty(ccbGetSceneNodeFromName(playerName),"PositionAbs");
var o_pos = ccbGetSceneNodeProperty(ccbGetSceneNodeFromName(objectName),"PositionAbs");
if(p_pos.x < o_pos.x + distance && p_pos.x > o_pos.x - distance
&& p_pos.z < o_pos.z + distance && p_pos.z > o_pos.z - distance)
return true;
else return false;
}

you can create node with billboard inside and set this function to visible, this will show and hide billboard (just "e" or "press e" text inside texture)
if you need i can upload some example


edwin123
Registered User
Quote
2022-12-13 19:05:20

that would help


samgrady
Registered User
Quote
2022-12-13 22:00:05

edwin123 https://drive.google.com/file/d/...
i trying to leave some comments but this example was really basic and easy so i got nothing to say, inside of scene you got two door one to move between room on one scene and other one send you to another scene
🔎︎



edwin123
Registered User
Quote
2022-12-14 00:05:15

thank you


gree
Registered User
Quote
2022-12-14 15:09:31

I like it too - thanks.
Reminds me of... :) https://www.youtube.com/watch?v=...


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inter?ational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact